I am working an application where I have to send emails asynchronously using Celery and RabbitMQ. How can I check if worker has sent email or failed?
Asked
Active
Viewed 96 times
0
-
yes it's possible – e4c5 May 24 '17 at 05:14
1 Answers
0
This SO explains what you are looking for.
Basically, Below is the what you need to do.
task_id = uuid()
result = sendemail.apply_async((), task_id=task_id)
Now you know exactly what the task_id is and can now use it to get the AsyncResult:
# grab the AsyncResult
result = celery.result.AsyncResult(task_id)
# print the task id
print result.task_id
09dad9cf-c9fa-4aee-933f-ff54dae39bdf
# print the AsyncResult's status
print result.status
SUCCESS
# print the result returned
print result.result
'Email sent successfully'

Jadav Bheda
- 5,031
- 1
- 30
- 28