0

I would like to ask a question according to Celery and Redis with my Django application. As I will explain further in details, I get some random issues with these applications.

My environment:

I'm using :

  • Django 1.11.20
  • django-redis 4.7.0 / redis >= 2.10.5
  • celery 4.2.1

My local context: (Ubuntu virtual machine)

I have a celery task which send an email with export file when this file is larger than 70.000 objects. The process works fine and I get the expected email with link to download my file.

Celery is started manually : celery -A main worker -l info

My dev context: (FreeBSD server)

I have exactly the same process. But celery is daemonized on my server. I can execute celery service with : service celeryd_app start

When I launch my celery task, sometimes I need to click on the button some times before to see :

Received task: app.tasks.get_xls_export[64d31ba5-73d9-4048-b19a-a4902fd904d7]

But the main issue that I have is : My task send an email with a specific email template located in /templates/email/email.html.

Sometimes it send this email template and sometimes it send an old template which doesn't exist in my project.

My question:

Is it possible that Celery/Redis has been kept in memory an old template ? There is a way to clean cache for my specific service ? Because I have other celery services on my server according to other applications.

Thank you very much !

Essex
  • 6,042
  • 11
  • 67
  • 139

1 Answers1

0

Looks like you have pending tasks if you want to clear the pending tasks

You can do by

from main.celery import app
app.control.purge()

or you can do celery -A main purge

If you want to discard tasks of specific queue you can do

celery amqp queue.purge <queue name>

Yugandhar Chaudhari
  • 3,831
  • 3
  • 24
  • 40
  • I tried `app.control.purge()`, but it doesn't seem to have any effect on my task. It looks like there is an old template stored somewhere (redis or celery) .. – Essex Mar 05 '19 at 13:47