IE9使本地Flask实例无响应
我正在开发的一个网页应用在Firefox和IE8下运行得很好。但是,当我尝试用IE9打开它时,页面加载了一段时间后就停止了。然后我再用Firefox打开同样的链接,它完全不加载。接着我重启了Flask,结果还是一样——我可以在Firefox上正常使用这个应用,但在IE9上却不行。看起来像是个bug,对吧?
这是Python抛出的异常信息:
Exception happened during processing of request from ('127.0.0.1', 6924)
Traceback (most recent call last):
File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python27\lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python27\lib\SocketServer.py", line 639, in __init__
self.handle()
File "C:\Users\Cosmo\AppData\Roaming\Python\Python27\site-packages\werkzeug\serving.py", line 189, in handle
return rv
UnboundLocalError: local variable 'rv' referenced before assignment
我把代码上传到我的主机上,那里运行得很好。
我觉得这个问题和这个讨论的情况类似。
2 个回答
2
我在使用最近版本的Flask/Werkzeug时,发现IE浏览器会让我的Flask服务器卡住,这个问题已经持续了两年多。后来我找到了解决办法,就是使用run(threaded=True)
,这个方法在另一个问题中有提到:我可以只用Flask的app.run()来同时服务多个客户端吗?
3
试试用 git 版本的 werkzeug。根据作者的说法,最近修复了一个类似的错误。