Skip to main content
 首页 » 编程设计

python之加载django模板时出现异常

2025年05月04日32lyj

我刚升级到 Django 1.5,在加载模板时看到这个异常:

Exception happened during processing of request from ('127.0.0.1', 50545) 
Traceback (most recent call last): 
  File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread 
    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 "/home/redacted/.virtualenvs/redacted/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 150, in __init__ 
    super(WSGIRequestHandler, self).__init__(*args, **kwargs) 
  File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__ 
    self.finish() 
  File "/usr/lib/python2.7/SocketServer.py", line 693, 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 

这只会在模板第一次加载时发生。所有后续请求都可以毫无问题地提供模板。

想法?

请您参考如下方法:

看起来这只是一个 old quirk with the dev server . django ticket已解决,因为不会修复。