问题描述
我的网站正在使用Django + Gunicorn + GEvent.我必须将Boto用于DynamoDB.
My website is using Django+Gunicorn+GEvent.There is a function which I have to use Boto for DynamoDB.
我需要打电话给monkey.patch_all()使Boto变成绿色吗?
Do I need call monkey.patch_all() to make Boto become greenlet?
推荐答案
如果使用默认的 worker_class 配置,则您不具备gevent功能.在此处中查看文档.我认为,即使您对所有补丁都进行了修补,使用默认配置时您也没有使用gevent的优势.
If you use the default worker_class configuration, then you don't have the features of gevent. Look the doc here. I think you don't have the advantage of using gevent when you use the default configuration even though you monkey patch all.
因此,您应该将gunicorn配置为使用执行monkey.patch_all()
操作的 GeventWorker ,在这种情况下,我认为您不必全都打补丁.这是GeventWorker
的源代码以及有关 worker_class
So you should configure gunicorn to use the GeventWorker which does the monkey.patch_all()
operation and in this situation, I think you don't have to monkey patch all. Here is the source code of GeventWorker
and the doc about worker_class
这篇关于我是否需要在Django + Gunicorn + GEvent + Boto结构中调用monkey.patch_all()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!