修补 Python 模块时 Django 中的 Gevent 异常
我已经安装了 gevent
和 greenlet
库,并在我的 Djano 应用程序的 __init__.py
文件中转储了这两行
from gevent import monkey
monkey.patch_all()
:我经常在 Django 控制台中看到这样的错误:
Exception KeyError: KeyError(27066240,) in <module 'threading' from 'C:\Program_Files\Python27\Lib\threading.pyc'> ignored
当我删除这两行时,我的应用程序工作得很好。以下是我在 Windows 计算机上使用的软件包的列表。
django-erroneous - 0.1.0 - active
Django - 1.3.1 - active
gevent - 0.13.6 - active
greenlet - 0.3.3 - active
lxml - 2.3.3 - active
PIL - 1.1.7 - active
pip - 1.0.2 - active
setuptools - 0.6c11 - active
South - 0.7.3 - active
virtualenv - 1.6.1 - active
yolk - 0.4.1 - active
Django 和 Gevent 是否存在兼容性问题?我在这里做错了什么吗?
仅供参考,我使用来自非官方 Python 存储库的预构建 Windows 二进制文件,这是一个开发环境。
I have installed the gevent
and greenlet
libraries and in the __init__.py
file of my Djano application I dumped in these two lines:
from gevent import monkey
monkey.patch_all()
Now it's very often I see errors in my Django console that read:
Exception KeyError: KeyError(27066240,) in <module 'threading' from 'C:\Program_Files\Python27\Lib\threading.pyc'> ignored
When I remove those two lines, my application works just fine. Here's a list of the packages I'm using on my Windows machine.
django-erroneous - 0.1.0 - active
Django - 1.3.1 - active
gevent - 0.13.6 - active
greenlet - 0.3.3 - active
lxml - 2.3.3 - active
PIL - 1.1.7 - active
pip - 1.0.2 - active
setuptools - 0.6c11 - active
South - 0.7.3 - active
virtualenv - 1.6.1 - active
yolk - 0.4.1 - active
Are there some compatibility issues with Django and Gevent? Am I doing something wrong here.
FYI, I'm using the pre-built Windows binaries from the unofficial Python repository and this is a development environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
昨天修复了与
patch_item
相关的monkey模块中的错误。建议使用固定版本进行任何进一步的测试。如果这没有帮助,您可以通过调用
patch_all
并将一些参数设置为 False 来缩小问题范围,并找出哪个模块对您来说有问题。我最终建议测试更窄的第一个是
monkey.patch_all(socket=False, select=False)
。这使得“dns”和“aggressive”也未被使用。您可以专注于套接字并单独选择,最后,如果可以安全地启用其他所有内容,则可以使用“dns”和“aggressive”。Yesterday has been fixed a bug in monkey module related to
patch_item
. Any further testing is recommended with the fixed version.If it does not help, you can make the problem narrower by calling
patch_all
with some arguments set to False and find which module is the problematic for you.The first what I eventually recommend to test narrower is
monkey.patch_all(socket=False, select=False)
. This makes "dns" and "aggressive" to be unused also. Than you can concentrate on socket and select separately and finally, if everything other can be safely enabled, on playing with "dns" and "aggressive".