通过 pdb 调试 djcelery 的 celeryd

Posted

技术标签:

【中文标题】通过 pdb 调试 djcelery 的 celeryd【英文标题】:Debugging djcelery's celeryd via pdb 【发布时间】:2011-05-31 10:44:00 【问题描述】:

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

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

有什么解决办法吗?

【问题讨论】:

【参考方案1】:

我遇到了同样的问题。尝试改用 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

请参阅user guide(链接更新 2017/5)。

【讨论】:

链接已更改。 docs.celeryproject.org/en/latest/tutorials/debugging.html 链接已更改...再次! docs.celeryproject.org/en/latest/userguide/debugging.html

以上是关于通过 pdb 调试 djcelery 的 celeryd的主要内容,如果未能解决你的问题,请参考以下文章

如何在Python自己的调试器(PDB)中执行多行语句

Python原生调试工具pdb实践小结

Roslyn 通过 EmbedAllSources 将源代码嵌入到 PDB 符号文件中方便开发者调试

尝试调试调用 C++ DLL 的 VBA,“未加载 wntdll.pdb”

[原]排错实战——解救加载调试符号失败的IDA

我用VC编写了一个exe,但是生成的pdb怎么也无法用于windbg调试