11

I've set up a Django project through Apache using mod_wsgi, and I'm now trying to add django-celery to the mix to run periodic and scheduled tasks. I'm running into occasional error messages, though, but I haven't found an explanation for what they mean.

When I start up Celerybeat using:

./manage.py celery beat

I often get one of the two following errors:

Message Error: cannot add item to database

celerybeat raised exception <class 'dbm.error'>: error('cannot add item to database',)

I can see that celerybeat generates two files in the project directory: celerybeat-schedule.dir and celerybeat-schedule.pag. I'm pretty sure these files are the "database" mentioned in the error message. If I delete these files, Celerybeat will usually run without problems for a couple times, but then the errors come back.

Is there something that I need to do with the celerybeat-schedule files to avoid this error? I thought it might be a permissions issue, but I couldn't see any issues.

1
  • 4
    remove this file: celerybeat-schedule.db Commented May 20, 2018 at 12:18

3 Answers 3

29

just rm celerybeat.db, and start you celerybeat again will work

Sign up to request clarification or add additional context in comments.

1 Comment

This worked. Seems what I did wrong was to purge running beat instance in htop using SIGKILL. But I when used SIGTERM, no such issue.
0

I was able to fix this by installing python3-gdbm (or python3-dbm) package and re-creating schedule file.

Comments

-1

Had the same issue and was not able to figure it out.

A workaround is to use the database to store the schedules:

celery -A proj beat -S djcelery.schedulers.DatabaseScheduler

You'll need to pip install django-celery and update your database if you go this route.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.