Database scheduler doesn't work with celerybeat
Database scheduler doesn't work with celerybeat due to the fact that background tasks don't fit the django periodic task model by default.
what do you mean here? could you elaborate?
I am having an issue with the database scheduler. I upgraded to 2.1 and ran syncdb to add the periodictask djcelery tables.
When I run:
$ ./manage.py celerybeat -S djcelery.schedulers.DatabaseScheduler
I get:
[2010-09-30 13:48:35,861: WARNING/MainProcess] celerybeat v2.1.0rc1 is starting.
[2010-09-30 13:48:35,872: WARNING/MainProcess] Configuration ->
. broker -> ghettoq.taproot.Database://guest@localhost/
. schedule -> celerybeat-schedule
. logfile -> @stderr@INFO
[2010-09-30 13:48:35,872: WARNING/MainProcess] celerybeat has started.
[2010-09-30 13:48:35,913: INFO/MainProcess] Celerybeat: Starting...
[Thu Sep 30 13:48:35 2010: CRITICAL/13029]: celerybeat raised exception <type 'exceptions.TypeError'>: __init__() got an unexpected keyword argument 'task'
Traceback (most recent call last):
File "/var/virtualenvs/celery/src/celery/celery/apps/beat.py", line 65, in start_scheduler
beat.start()
File "/var/virtualenvs/celery/src/celery/celery/beat.py", line 292, in start
humanize_seconds(self.scheduler.max_interval)))
File "/var/virtualenvs/celery/src/celery/celery/beat.py", line 326, in scheduler
self._scheduler.update_from_dict(self.schedule)
File "/var/virtualenvs/celery/src/celery/celery/beat.py", line 216, in update_from_dict
for name, entry in dict_.items()))
File "/var/virtualenvs/celery/src/celery/celery/beat.py", line 216, in <genexpr>
for name, entry in dict_.items()))
TypeError: __init__() got an unexpected keyword argument 'task'
Though everything works fine if I use the default scheduler.
-s is the scheduler database file used for the default scheduler.
Please pull from django-celery master now, and the bug should be fixed!
Pulling the latest changes did the trick. I am now able to use the database scheduler. Very cool!
However, I am still getting some strange behavior. When I experiment with different intervals, the tasks always seem to happen at 5 second intervals. It doesn't matter if I choose 20 seconds or 1 minute, the tasks are executed every 5 seconds. One exception is microseconds which seems to work as expected.
I'm using built-in celery.ping task for creating periodic tasks. After selecting "one minute" as the interval, I still get output like this in my log every 5 seconds:
[2010-10-04 15:47:29,730: INFO/MainProcess] Task celery.ping[bca6978b-2129-4b9d-aa73-e934c442fee4] processed: 'pong'
[2010-10-04 15:47:34,711: INFO/MainProcess] Got task from broker: celery.ping[fa9c16c3-65b7-4c69-a746-698589a59b77]
[2010-10-04 15:47:34,737: INFO/MainProcess] Task celery.ping[fa9c16c3-65b7-4c69-a746-698589a59b77] processed: 'pong'
Any guidance is much appreciated.
DatabaseScheduler didn't properly store last_run_at. Closed by 8a44c8786ee94e7713ce5b5331e1866945880490
Hah. Yeah, I noticed this too yesterday the hard way. When I came home after work my workers had processed half a million tasks, and there were 3 million more waiting in the queue ;) Nice to see RabbitMQ 2.x surviving, it did work, but with a load of 2+.
I fixed this in celery commit ask/celery@9b5c47c42804b4f3cf4d55a6ef55bdad7791b04f and django-celery commit 8a44c8786ee94e7713ce5b5331e1866945880490.
Please test!