# track celery task with django application

**URL:** <https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982>\
**Category:** Deployment\
**Created:** [February 5, 2022, 5:56pm UTC](https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982 "2022-02-05T17:56:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LameesKadhim](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@LameesKadhim](https://forum.djangoproject.com/u/LameesKadhim)\
**Post date:** [February 5, 2022, 5:56pm UTC](https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982/1 "2022-02-05T17:56:22Z")

</div>

Hi all,  
I am working on a web application that has celery tasks running on the background. I am using visual studio code and I want to track the celery task. any idea how to do that?  
Thanks

---

<div class="post-metadata">

**Author:** ![blaketig](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/blaketig/32/6323_2.png) [@blaketig](https://forum.djangoproject.com/u/blaketig)\
**Post date:** [February 6, 2022, 12:03am UTC](https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982/2 "2022-02-06T00:03:11Z")

</div>

One option is [Flower - Celery monitoring tool — Flower 1.0.1 documentation](https://flower.readthedocs.io/en/latest/) for monitoring Celery.

---

<div class="post-metadata">

**Author:** ![LameesKadhim](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@LameesKadhim](https://forum.djangoproject.com/u/LameesKadhim)\
**Post date:** [February 6, 2022, 11:35am UTC](https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982/3 "2022-02-06T11:35:08Z")

</div>

Thank you very much, but I want to track the excution steps of one of the celery tasks. I want to see the value of the variables when code is being excuted like debugging but I couldn’t do debug to the celery task because it is running on the background. so any suggested approach please?

---

<div class="post-metadata">

**Author:** ![blaketig](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/blaketig/32/6323_2.png) [@blaketig](https://forum.djangoproject.com/u/blaketig)\
**Post date:** [February 7, 2022, 3:33am UTC](https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982/4 "2022-02-07T03:33:59Z")

</div>

Hmm sorry I’m not sure on that hopefully someone else here may know.

---

<div class="post-metadata">

**Author:** ![yassi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/yassi/32/16340_2.png) [@yassi](https://forum.djangoproject.com/u/yassi)\
**Post date:** [October 9, 2023, 3:26am UTC](https://forum.djangoproject.com/t/track-celery-task-with-django-application/11982/5 "2023-10-09T03:26:36Z")

</div>

The most straightforward approach is to use some form of remote debugger. The celery docs actually have a section specifically for this: [Debugging — Celery 5.3.4 documentation](https://docs.celeryq.dev/en/stable/userguide/debugging.html)  
Other remote debuggers exist that would allow you to similarly set a trace point.

Another approach is to use the usual pdb.set\_trace() but limit the task to be synchronous for the purposes of your test/debugging session. This also would be in local dev environment

1. your settings should have CELERY\_ALWAYS\_EAGER=True
2. open up a shell (i.e. python manage.py shell)
3. import your task within the shell environment (from app.blah import TestTask)
4. run the task and the pdb break point will be reached and execution will stop
5. you can treat this like a usual debugging session from here.

The second approach is useful for simple testing and debugging. The first approach is a more accurate way since it mirrors a more realistic deployment environment.
