为什么Django开发服务器挂在这个管理工具JS文件上? [英] Why does the Django development server hang on this admin tool JS file?
问题描述
定期使用Django管理工具时,它会挂起并停止响应请求,直到重新启动。每当挂起时,日志中的最后一行是:
Periodically, when using the Django admin tool, it hangs and stops responding to requests until it is restarted. Whenever it hangs, the last line in the log is:
GET / admin / jsi18n / HTTP / 1.1200 2158
"GET /admin/jsi18n/ HTTP/1.1" 200 2158
挂起似乎发生在POST之后(如查看添加对象的结果)。它发生在各种不同的模型,是不可预测的,据我所知。唯一的常量是对该Javascript文件的GET请求。此外,挂起之间的时间有所不同:有时您可以使用管理工具添加一个小时的对象,有时不能持续5分钟。
The hang seems to occur after a POST (like when viewing the results of adding an object). It happens with a variety of different models and is unpredictable, as far as I can tell. The only constant is the GET request to that Javascript file. Also, the time between hangs varies: sometimes you can add objects with the admin tool for an hour, sometimes it can't last 5 minutes.
性能方面,框似乎没有受到很大的压力(负载平均值为0.17-0.20)
Performance-wise, the box does not appear to be under much stress (load average of 0.17-0.20)
它最近输出一个看起来很有趣的错误,虽然它恢复了自己,并在以后继续提供服务:
It recently output an error that looks interesting, though it recovered itself and kept serving responses afterwards:
[18/Aug/2011 13:19:50] "GET /admin/jsi18n/ HTTP/1.1" 200 2158
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 284, in run
self.finish_response()
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 324, in finish_response
self.write(data)
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 420, in write
self._write(data)
File "/usr/lib/python2.6/socket.py", line 300, in write
self.flush()
File "/usr/lib/python2.6/socket.py", line 286, in flush
self._sock.sendall(buffer)
error: [Errno 32] Broken pipe
推荐答案
很可能是因为您使用Google Chrome。这将使多达一个连接到Web服务器的连接,在Django Dev服务器的情况下,这是不好的。你有两个选择。
使用
Most likely this is because of you using Google Chrome. Which will make more then one connection to a web-server, which in the case of the Django Dev server it's no good. You have two options. Either use
- Django并发服务器
- 使用生产服务器设置您的开发者服务器(不推荐,更复杂)
- 使用Firefox,告诉Chrome停止多个连接
- 使用单独的服务器在计算机上托管静态文件。喜欢Lighttpd或某些东西。
- Django Concurrent Server
- Setup your dev-server using a production server (Don't recommend, more complex)
- Use Firefox, tell Chrome to stop multiple connections
- Host your static files on your computer using a separate server. Like Lighttpd or something.
这篇关于为什么Django开发服务器挂在这个管理工具JS文件上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!