My app gathers a bunch of phone numbers on a page. Once the user hits the submit button I create a celery task to call each number and give a reminder message then redirect them to a page where they can see the live updates about the call. I am using web sockets to live update the status of each call and need the tasks to execute synchronously as I only have access to dial out from one number.
So once the first call/task is completed, I want the next one to fire off.
I took a look at CELERY_ALWAYS_EAGER settings but it just went through the first iteration and stopped.
JavaScript
x
10
10
1
@task
2
def reminder(number):
3
# CODE THAT CALLS NUMBER HERE....
4
5
def make_calls(request):
6
for number in phone_numbers:
7
reminder.delay(number)
8
9
return redirect('live_call_updates')
10
Advertisement
Answer
if you want to fire each call one after another, why dont you wrap all the calls in one task
JavaScript
1
10
10
1
@task
2
def make_a_lot_of_calls(numbers):
3
for num in numbers:
4
# Assuming that reminder blocks till the call finishes
5
reminder(number)
6
7
def make_calls(request):
8
make_a_lot_of_calls.delay(phone_numers)
9
return redirect('live_call_updates')
10