How do I enable remote celery debugging in PyCharm?

前端 未结 8 1050
-上瘾入骨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:27

    in Windows , Add the following params in your debugging conf in Pycharm

    -A YouAppName worker  --loglevel=debug -P solo --without-gossip --without-mingle --without-heartbeat
    
    0 讨论(0)
  • 2020-12-23 21:27

    My working configuration:

    • Script: /home/app/env/bin/celery
    • Script parameters: worker -B -n qrc -Q qrc -l info --app=backend.celery

      • Where -B is for celerybeet, -n is node name, -Q is queue name, -l is log level, and --app is the app name, a django app with celery.py next to settings.py in my case.
    • Working directory: /home/app/server/ ie my django root folder

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

    You can have a Run Configuration to run your celery workers which then allows you to debug simply by clicking the debug button. Here is how I set that up in PyCharm 5:

    You need to set up a remote python interpreter and then set other configs like the image above. Note that the Working directory is pointing to the bin folder of the remote interpreter with celery installed.

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

    If you are using Gevent for Celery do not forget to check Preferences > Build, Execution, Deployment > Python Debugger > Gevent Compatible checkbox.

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

    I'm using PyCharm 2017 and had to do something very similar to the answers above, but I specifically had to put the full/absolute path name to celery in the "Script" field

    Also, I'm not sure if PyCharm 4 has this feature, but newer versions allow you to attach directly to a running python process by going to Run > Attach to Local Process...

    This allows you to run celery however you were before (in the terminal, perhaps) then allow Pycharm to take over

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

    Just add the following config:

    from celery import current_app
    current_app.conf.CELERY_ALWAYS_EAGER = True
    current_app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
    

    Doing so makes celery execute in the same thread as the currently executing thread.

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