在Django Nonrel加载localhost时出现Broken pipe错误
我在使用Django Nonrel,搭配Google App Engine 2.6.0和Python 2.7的时候,第一次尝试访问localhost和localhost/admin时,遇到了一个异常(我猜任何页面都会出现这个问题):
Exception happened during processing of request from ('127.0.0.1', 57011)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver.py", line 2438, in __init__
BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 641, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 694, in finish
self.wfile.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
奇怪的是,这个问题只在使用Google Chrome时出现。而在Firefox中,我没有看到任何异常(或者说,我尝试了很多次都没能在Firefox中重现这个问题)。
有没有人知道这个问题是怎么回事?
谢谢
1 个回答
6
有一些关于Chrome和dev_appserver.py之间出现竞争条件的问题的讨论。通常的情况是,Chrome会同时打开多个连接到服务器,但它会先在第二个连接上发送请求。由于dev_appserver是单线程的,第一个请求就会被阻塞,服务器就会卡住,直到有人放弃。
据说用 --disable-preconnect
启动Chrome可以防止这种情况发生。