19👍
✅
delay
will work. This method is convenient as it looks like calling a regular function: see doc here
task_a.delay(*arg,**kwargs)
delay
is clearly convenient, but if you want to set additional execution options you have to use apply_async
.
task_a.apply_async(args=[arg1, arg2])
Note that the argument passed is a list.
12👍
To pass arguments to task with apply_async()
you need to wrap them in a list and then pass the list as first argument, I.e. apply_async([arg1, arg2, arg3])
. See the documentation for more details and examples.
Use delay()
as an alternative. The benefit is that it preserves more or less function’s parameters interface, i.e. it is not needed to wrap the args in a list.
- Is there any way to use GUIDs in django?
- PyCharm does not resolve templates nor template tags nor statics in Django project
Source:stackexchange.com