35👍
✅
From basic part of celery Calling documentation
delay(*args, **kwargs)
Shortcut to send a task message, but doesn’t support execution
options.So delay is clearly convenient, but if you want to set additional
execution options you have to use apply_async.
As documentation states delay
cannot be used with additional options set so you should just convert your call into apply_async
If you want to add execution options, the docs suggest you use a signature. e.g:
my_task.s(arg1, arg2).apply_async(countdown=60)
27👍
Just to add to iklinac’s answer. This is how you would call the task using apply_async()
my_task.apply_async(args=(param1, param2), countdown=60)
or
my_task.apply_async(kwargs={'param1':param1, 'param2':param2}, countdown=60)
The second option will really come in handy if you are using a tool like Flower for monitoring. You can look at Celery tasks best practices page for other tips.
- [Django]-Django python date time set to midnight
- [Django]-How to ignore directories when running Django collectstatic?
- [Django]-Django url debugger
Source:stackexchange.com