Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Celery Automatically Monkey Patch when running eventlet pool?

This is a cross-post from the mailing list, hoping to get more eyes on the question. (original post)

When using running celery worker -p eventlet, does Celery do automatic monkey-patching of my code?

The docs don't mention anything about having to do patching and the official example doesn't do any explicit patching as well (even the gevent example doesn't do any patching). The example hints at patching being done automatically, but there is no explicit/definite answer.

like image 383
john2x Avatar asked Mar 08 '16 02:03

john2x


1 Answers

When you run celery worker the function execute_from_commandline calls celery.__init__.maybe_patch_concurrency which calls _patch_eventlet which does:

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)
like image 158
scytale Avatar answered Sep 24 '22 20:09

scytale