Visit the Community Forum to learn more and ask any questions you have!

Problem with scheduled tasks

Back to Thread List

I'm trying to set up scheduled tasks but running into this exception when I deploy:

Traceback (most recent call last):
File "/opt/python/run/venv/local/lib/python3.6/site-packages/celery/beat.py", line 476, in setup_schedule
self._store = self._open_schedule()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/celery/beat.py", line 466, in _open_schedule
return self.persistence.open(self.schedule_filename, writeback=True)
File "/usr/lib64/python3.6/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib64/python3.6/shelve.py", line 227, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/lib64/python3.6/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: Bad magic number

Any idea what I can do to fix this?

by morphos23 on Aug. 11, 2024, 4:34 p.m.

Replies

  • Sorry you're having an issue! Luckily we can fix this problem easily.

    The issue is that Celery wants to track the last time your task was run by storing that data in a file. But when you re-deploy we terminate the instance, and that file can become corrupt in the process.

    To use scheduled tasks on Circumeo, you'll need to make sure the django-celery-beat package is in requirements.txt and INSTALLED_APPS (as the module name django_celery_beat).

    Once you have it installed, add the following line to settings.py:

    CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"

    You'll then want to run the migrations for the package.

    python manage.py migrate django_celery_beat

    You can find more info on the docs website: https://docs.circumeo.io/en/celery-integration

    Hope that helps!

    by zach on Aug. 11, 2024, 4:40 p.m.
Reply to this thread