Skip to content

Instantly share code, notes, and snippets.

@igniteflow
Created January 24, 2012 10:51
Show Gist options
  • Select an option

  • Save igniteflow/1669588 to your computer and use it in GitHub Desktop.

Select an option

Save igniteflow/1669588 to your computer and use it in GitHub Desktop.
Fix for Django runserver: [Errno 32] Broken pipe
"""
The problem is caused by the client terminating the call before the job is processed. To fix, add in the ThreadingMixIn as recommended here by Edward Samson (for a different, but related problem) here https://bitbucket.org/edu/woof/issue/1/errno-32-broken-pipe-upon-accessing-woof
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 41598)
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/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
----------------------------------------
Edit: /home/ptysoe/.virtualenvs/.../lib/python2.x/site-packages/django/core/servers/basehttp.py +562
"""
# change
class WSGIRequestHandler(BaseHTTPRequestHandler):
# to
from SocketServer import ThreadingMixIn
class WSGIRequestHandler(BaseHTTPRequestHandler, ThreadingMixIn):
@igniteflow
Copy link
Author

Valid for Django==1.2.3

@daGrevis
Copy link

daGrevis commented Feb 5, 2013

Doesn't work for Django 1.4.3.

@yjp211
Copy link

yjp211 commented May 7, 2013

Doesn't work for Django 1.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment