运行eventlet池时Celery会自动运行Monkey Patch吗?

joh*_*n2x 6 python django celery eventlet

这是来自邮件列表的交叉帖子,希望能够更多地关注这个问题.(原帖)

在使用跑步时celery worker -p eventlet,Celery会自动对我的代码进行猴子修补吗?

文档没有关于必须做修补和提什么官方的例子没有做任何明确的补丁以及(甚至GEVENT例如不进行任何修补).该示例提示自动完成修补,但没有明确/确定的答案.

scy*_*ale 7

当您运行celery worker函数execute_from_commandline调用celery.__init__.maybe_patch_concurrencywhich 调用_patch_eventletwhich 执行以下操作时:

def _patch_eventlet():
    import eventlet
    import eventlet.debug

    eventlet.monkey_patch()
    blockdetect = float(os.environ.get('EVENTLET_NOBLOCK', 0))
    if blockdetect:
        eventlet.debug.hub_blocking_detection(blockdetect, blockdetect)
Run Code Online (Sandbox Code Playgroud)