通过pdb调试djcelery的celeryd

Jee*_*Kim 21 python django debugging celery

有没有人尝试使用pdb调试celeryd worker?每当遇到断点时(通过pdb或by运行celeryd pdb.set_trace()),我都会遇到以下错误:

Error while handling action event.
Traceback (most recent call last):
  File "/home/jeeyo/workspace3/uwcr/subscriptions/tasks.py", line 79, in process_action_event
    func(action_event)
  File "/home/jeeyo/workspace3/uwcr/subscriptions/tasks.py", line 36, in new_user_email
    send_registration_email(username, new_user.get_profile().plaintext_password)
  File "/home/jeeyo/workspace3/uwcr/looers/email.py", line 18, in send_registration_email
    'Your password from UWCoopRankings', user
  File "/home/jeeyo/workspace3/uwcr/looers/email.py", line 61, in send_email
    if isinstance(to, basestring):
  File "/home/jeeyo/workspace3/uwcr/looers/email.py", line 61, in send_email
    if isinstance(to, basestring):
  File "/usr/lib/python2.6/bdb.py", line 46, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/lib/python2.6/bdb.py", line 65, in dispatch_line
    if self.quitting: raise BdbQuit
BdbQuit
Run Code Online (Sandbox Code Playgroud)

对此有何解决方案?

AMO*_*AMO 18

我有同样的问题.尝试使用Celery的远程调试器rdb:

from celery import task
from celery.contrib import rdb

@task()
def add(x, y):
    result = x + y
    rdb.set_trace()  # <- set break-point
    return result
Run Code Online (Sandbox Code Playgroud)

请参阅用户指南(链接更新2017/5).

  • 链接已更改.http://docs.celeryproject.org/en/latest/tutorials/debugging.html (2认同)
  • 链接再次更改:https://docs.celeryq.dev/en/stable/userguide/debugging.html (2认同)