How do I enable remote celery debugging in PyCharm?

前端 未结 8 1051
-上瘾入骨i
-上瘾入骨i 2020-12-23 21:11

I\'m trying to find some instructions on how to enable PyCharm debugging within my celery processes on a remote machine. The remote machine is running Ubuntu 14.04.

相关标签:
8条回答
  • 2020-12-23 21:45

    For Windows, tested in with Celery >= 4.0

    Add a new (Run/Debug) configuration of type "Python":

    Then, Under configuration tab: switch the first option (Target to run) from "Script path" to "Module name" and fill in the value:

    celery.bin.celery
    

    like the snapshot below:

    0 讨论(0)
  • 2020-12-23 21:49

    Unfortunately, most solutions don't work on Windows. (There was a separate question specifically about that, but unfortunately it got closed as a duplicate of this one. So I'll answer that question here now.)

    The problem is that on Windows, the standalone celery command is a batch file, so PyCharm cannot attach the Python debugger to it.

    Up until Celery 3.x, you can create a manage.py run configuration and call the celery worker command on it.

    Note that you don't need to set --app here, as the application is defined by the management command via DJANGO_SETTINGS_MODULE.

    Unfortunately, the celery management command was a feature of the django-celery library, which isn't supported by Celery 4.x. As of yet, I haven't found a solution for Celery 4.x.

    0 讨论(0)
提交回复
热议问题