Home > Mobile >  celery with Django
celery with Django

Time:10-11

I am building a app and I am trying to run some tasks everyday. So I saw some answers, blogs and tutorials about using celery, So I liked the idea of using celery for doing background jobs.

But I have some questions about celery :-

As mentioned in Celery Documentation that after setting a celery task , I have to run a command like celery -A proj worker -l INFO which will process all the tasks and after command it will run the tasks, so my question is , I have to stop the running server to execute this command and what if I deploy Django project with celery on Heroku or Python Anywhere.

Should I have to run command every time Or I can execute this command first then i can start the server ?

If I have to run this command every time to perform background tasks then how is this possible when deploying to Heroku,

Will celery's background tasks will remain running after executing python manage.py run server in only terminal ?

Why I am in doubt ? :-

What I think is, When running celery -A proj worker -l INFO it will process (or Run) the tasks and I cannot execute run server in one terminal.

Any help would be much Appreciated. Thank You

CodePudding user response:

Should I have to run command every time Or I can execute this command first then i can start the server ?

Dockerize your Celecry and write your own script for auto-run.

CodePudding user response:

You can't run celery worker and django application in one terminal simultaneously, because both of them are programs that should be running in parallel. So you should use two terminals, one for django and another for celery worker.
I highly recommend to read this heroku development article for using Celery and Django on heroku.

  • Related