1👍
✅
generateCodes.apply_async(args=[product_id, amount_to_gen])
If you run it like generateCodes(..) it will run it as a normal blocking method.
0👍
When you call generateCodes(product_id, amount_to_gen)
, you are bypassing Celery’s distributed facilities.
For the sake of convenience, Celery defines its task object so that simply calling the task like you do will just call the task, just like you call any function in Python. This is described here:
calling (
__call__
)Applying an object supporting the calling API (e.g.
add(2, 2)
) means that the task will be executed in the current process, and not by a worker (a message will not be sent).
Note how it says "not by a worker". That’s your problem. You’d have to call generateCodes.apply_async(product_id, amount_to_gen)
to have your task executed by a worker.
- Custom validation in django admin breaks datetime widget
- HttpResponseRedirect with reverse not passing parameters
- IntegrityError at /admin/main/category/add/ NOT NULL constraint failed: main_category.author_id
Source:stackexchange.com