Django is sooo slow? errno 32 broken pipe? dcramer

2020-08-25 09:01发布

问题:

I've been using Django 1.3 with Python 2.6 on Ubuntu 10.10. I have 3 questions.

  1. I recall having this problem on Windows 7 when I used Django a while ago. However, I also remember that when I first used Django this problem didn't occur.

When I access Django via 127.0.0.1:8000, after starting a brand new project, I can reach the site, but sometimes it takes a good 10-20 secs and sometimes more to reach it. Also, on a project I've barely worked on, I have the same problems and also get errors like:

Exception happened during processing of request from ('127.0.0.1', 47758)
Traceback (most recent call last):
  File "/usr/lib/python2.6/SocketServer.py", line 283, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 309, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/servers/basehttp.py", line 570, in __init__
    BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "/usr/lib/python2.6/SocketServer.py", line 618, in __init__
    self.finish()
  File "/usr/lib/python2.6/SocketServer.py", line 661, in finish
    self.wfile.flush()
  File "/usr/lib/python2.6/socket.py", line 297, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
  1. Also, whenever I get an error I expect dcramer's django-sentry to log the error in the database, but when I go into MySQL and check the tables, there is nothing there. I followed the instructions on the site to install the app.

  2. I placed this in my urls.py file:

    url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/user/apache2/www/django/ecomstore/static',})
    

However, when I go to 127.0.0.1:8000/static/css.css I can't find the file I placed in the folder. What did I do wrong?

Thanks for all the help!

回答1:

this issue is also discussed here Django + WebKit = Broken pipe



回答2:

These errors are the client closing the connection before it has a chance to fully send all data (I believe).

There are certain areas of the stack, this being one of them, that Sentry currently can't log exceptions from. We're hoping to improve this in Sentry 2.0.



回答3:

/Have you set STATIC_URL = '/static/' in your settings