Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery + Django: Cannot start celerybeat on Windows 7

I've been developing a Django application and I am now trying to add Celery for background tasks. I need both normal tasks and periodic tasks to be queued. I can start up celeryd just fine, and execute tasks with it (I start it with the command python manage.py celeryd start --settings=settings --loglevel=INFO).

On Windows you can't do -beat/-b to enable beat mode; you need to start celerybeat as a separate service (this is stated in the FAQ section of the Celery docs). If I type this into the command line -- python manage.py celerybeat -s djcelery.schedulers.DatabaseScheduler --settings=settings --loglevel=INFO -- I get an error like this:

[2012-01-02 19:06:52,009: WARNING/MainProcess] ERROR: Pidfile (celerybeat.pid) a
lready exists.
Seems we're already running? (PID: 2364)
[2012-01-02 19:06:52,012: INFO/MainProcess] process shutting down

and celerybeat never actually starts. So I can't execute any periodic tasks ... Any ideas? I only found one other page where somebody highlighted a similar error, but no solution was offered.

If there's any further information needed, please let me know. I'm baffled because I can't find any information on this subject, and I've been trying solve this problem all day today ... Thank you.

like image 793
m_floer Avatar asked Jan 03 '12 00:01

m_floer


People also ask

Why celery is used in Django?

Celery makes it easier to implement the task queues for many workers in a Django application.


2 Answers

Search your file system for that pid file and delete it. On unix machines that usually means the program was not shut down correctly. You should check to see if its running in the task manager already, if so kill it, and delete that file

Then try again.

If there is no pid file present, that probably means there's an issue with the software as it was ported from unix perhaps?

like image 72
tkone Avatar answered Oct 23 '22 14:10

tkone


In my case of django project on Windows this file was already existing in root of the Django project. I deleted that file and the process ran without any error. enter image description here

The "celerybeat.pid" was already existing because I ran celery beat from another PC and pushed the git repo to the cloud. When I pulled the repo on my working PC and ran the process, it gave me error referring to the file "celerybeat.pid" created earlier by another PC. Deleting the "celerybeat.pid" made it work.

like image 34
javed Avatar answered Oct 23 '22 13:10

javed