Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging djcelery's celeryd via pdb

Tags:

Have anybody tried debugging celeryd worker using pdb? Whenever a breakpoint is encountered (either by running celeryd via pdb, or by pdb.set_trace()), I hit the following error:

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 

Any solution to this?

like image 687
Jeeyoung Kim Avatar asked Dec 28 '10 05:12

Jeeyoung Kim


People also ask

How do you debug celery?

First, I open my project in Eclipse and put a breakpoint at the beginning of the task function. Then, I'm starting the Celery workers from Eclipse by Right Clicking on manage.py from the PyDev Package Explorer and choosing "Debug As->Python Run" and specifying "celeryd -l info" as the argument.

What is pdb debugging?

The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame.

How do you debug celery in Pycharm?

Go to Edit Configuration , then select the '+' icon to add new Python script and enter the celery path, other parameters and working directory. You can specify environment variables and bottom of that you have the option to select parent environment to include as well.


1 Answers

I had the same problem. Try using Celery's remote debugger rdb instead:

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 

See the user guide (link update 2017/5).

like image 61
AMO Avatar answered Oct 01 '22 11:10

AMO