I have read quite a few posts that are similar to this but none seem to make sense to me.
I am trying to configure a Celery PeriodicTask to fire every 5 seconds but I'm getting hung up on a Celery configuration issue (I think)
comm/tasks.py
import datetime
from celery.decorators import periodic_task
@periodic_task
def send_queued_messages():
# do something...
myapp/settings.py
...
from comm.tasks import send_queued_messages
from datetime import timedelta
CELERYBEAT_SCHEDULE = {
'send_queued_messages_every_5_seconds': {
'task': 'comm.tasks.send_queued_messages', # Is the issue here? I've tried a dozen variations!!
'schedule': timedelta(seconds=5),
},
}
The relevant output from my error logs:
23:41:00 worker.1 | [2015-06-10 03:41:00,657: ERROR/MainProcess] Received unregistered task of type 'send_queued_messages'.
23:41:00 worker.1 | The message has been ignored and discarded.
23:41:00 worker.1 |
23:41:00 worker.1 | Did you remember to import the module containing this task?
23:41:00 worker.1 | Or maybe you are using relative imports?
23:41:00 worker.1 | Please see http://bit.ly/gLye1c for more information.
23:41:00 worker.1 |
23:41:00 worker.1 | The full contents of the message body was:
23:41:00 worker.1 | {'utc': True, 'chord': None, 'args': [], 'retries': 0, 'expires': None, 'task': 'send_queued_messages', 'callbacks': None, 'errbacks': None, 'timelimit': (None, None), 'taskset': None, 'kwargs': {}, 'eta': None, 'id': 'a8ca18...227a56'} (216b)
See the celery docs for an explanation on task naming.
In this case you need to provide celerybeat with a task name that it can find.
try this: