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
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313

2 Answers2

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.

Ahmed
  • 2,825
  • 1
  • 25
  • 39
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('/')
Ahmed
  • 2,825
  • 1
  • 25
  • 39
Kuldeep Rishi
  • 488
  • 5
  • 16