django的开发服务器在OSX上有时很慢

时间:2011-04-15 08:36:28

标签: django macos

当我跑步时:

python manage.py runserver

开发服务器启动时没有错误消息,但有时加载页面只会挂起一两分钟,然后非常慢地加载页面。我正在运行OSX 10.6.6,virtualenv,django 1.3,python 2.6.1,mysql。在3个不同的mac上发生在多个项目上。

其他人有同样的问题吗?

偶尔我会看到这个:

    Traceback (most recent call last):
  File "/Users/x/webdev/99/svn/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 284, in run
    self.finish_response()
  File "/Users/x/webdev/99/svn/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 324, in finish_response
    self.write(data)
  File "/Users/x/webdev/99/svn/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 403, in write
    self.send_headers()
  File "/Users/x/webdev/99/svn/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 467, in send_headers
    self.send_preamble()
  File "/Users/x/webdev/99/svn/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 385, in send_preamble
    'Date: %s\r\n' % http_date()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py", line 297, in write
    self.flush()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py", line 284, in flush
    self._sock.sendall(buffer)
error: [Errno 32] Broken pipe

2 个答案:

答案 0 :(得分:3)

静态媒体使我放慢速度,所以我现在通过apache为他们服务。问题解决了。

Making Django development server faster at serving static media

答案 1 :(得分:1)

在OSX上没有Django的问题,并用它做了几个项目。

正如tiagoboldt建议您可能需要检查瓶颈的代码。调试工具栏有助于分析查询性能。

http://jacobian.org/writing/django-performance-tips/

也有一些好建议