error: [Errno 32] Broken pipe django
Asked Answered
H

2

7

Sometimes when i look at my terminal, i am seeing the below error, can anyone please let me know y it is displaying and how to avoid it ?

Exception happened during processing of request from ('127.0.0.1', 39444)
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/comp/Envs/proj/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
Hydrostatic answered 20/11, 2013 at 18:21 Comment(1)
Check out the most voted answer #7913172Carlottacarlovingian
E
6

You get that error due two of the following reasons. You might see the same issue due to other reasons as well

1-You're missing / at the end of your url and you can fix it by fixed by added "/" to the end of the URL you request

2-You make some requests then quickly stop it. Like calling a url then cancelling the call and call another url. Check where do you make your calls (JavaScript or backend) and make sure you call the url without cancelling it.

Eulau answered 30/10, 2014 at 7:15 Comment(0)
F
2

This might be because you are using two method for inserting data into database and this cause the site to slow down.

def add_subscriber(request, email=None):
    if request.method == 'POST':
        email = request.POST['email_field']
        e = Subscriber.objects.create(email=email).save()  <==== 
        return HttpResponseRedirect('/')
    else:
        return HttpResponseRedirect('/')

eg. in above function error is where arrow is pointing the correct way to implement above is

def add_subscriber(request, email=None):
    if request.method == 'POST':
        email = request.POST['email_field']
        e = Subscriber.objects.create(email=email)
        return HttpResponseRedirect('/')
    else:
        return HttpResponseRedirect('/')
Finality answered 17/1, 2014 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.