I use django, celery and redis to launch task asynchronously.
# tasks.py
@shared_task
def my_task():
# Do stuff of task 1
return True
# Somewhere in test1.py
my_task.delay()
# Few milli seconds later in test2.py
my_task.delay()
With that configuration, my_task is launched 2 times on 2 different files. So they are executed on different threads almost at the same time.
I need these 2 tasks to be executed one by one. If my_task #1 is executing and another my_task #2 is launched, I need my_task #2 to wait for the #1 to end before executing.
I don't want to use only one thread passing argument to celery celery worker --concurrency=1
Config of celery in my settings.py is basic :
# settings.py
CELERY_BROKER_URL = 'redis://localhost:6379/0'
I found many resources who talks about that subject but I don't really understand how to achieve my goal