How to run all celery tasks without workers, I mean call directly? I can call task with TaskName.run(), but I want to write this in configurations, so how to make it?
Just set the CELERY_ALWAYS_EAGER settings to true, this will force celery not to queue the tasks and run them synchronously in the current process.
If you want to be able to do it per specific task, you can run them with apply() or run() as you mentioned, instead of running them with apply_async() or delay().
So tl;dr:
CELERY_ALWAYS_EAGER = True
# The following two would do and act the same, processing synchronously
my_task.run()
my_task.delay()
But
CELERY_ALWAYS_EAGER = False
# These two won't be the same anymore.
my_task.run() # Runs synchronously
my_task.delay() # Passed to the queue and runs Asynchronously, in another process
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With