Skip to main content

A Celery Beat Scheduler that uses MongoDB to store both schedule definitions and status information

Project description

celerybeat-mongo

This is a Celery Beat Scheduler that stores both the schedules themselves and their status information in a backend Mongo database. It can be installed by installing the celerybeat-mongo Python egg:

# pip install celerybeat-mongo2

And specifying the scheduler when running Celery Beat, e.g.:

$ celery beat -S celerybeatmongo.schedulers.MongoScheduler

Settings

The settings for the scheduler are defined in your celery configuration file similar to how other aspects of Celery are configured:

  • mongodb_scheduler_url: The mongodb url connection used to store task results.

  • mongodb_scheduler_db: The Mongodb database name

  • mongodb_scheduler_collection (optional): the collection name used by model. If no value are specified, the default value will be used: schedules.

Usage

Celerybeat-mongo just supports Interval and Crontab schedules. Schedules easily can be manipulated using the mongoengine models in celerybeat mongo.models module.

Example creating interval-based periodic task

To create a periodic task executing at an interval you must first create the interval object:

from celery import Celery
from celerybeatmongo import PeriodicTask, connect_from_app

app = Celery("hello")
app.conf.update(
    mongodb_scheduler_db="my_project",
    mongodb_scheduler_url="mongodb://localhost:27017",
)
connect_from_app(app)

periodic = PeriodicTask(
    name='Importing contacts',
    task="proj.import_contacts",
    schedule=PeriodicTask.Interval(every=10, period="seconds"),
)
periodic.save()

Example creating crontab periodic task

A crontab schedule has the fields: minute, hour, day_of_week, day_of_month and month_of_year, so if you want the equivalent of a 30 7 * * 1 (Executes every Monday morning at 7:30 a.m) crontab entry you specify:

from celery import Celery
from celerybeatmongo import PeriodicTask, connect_from_app

app = Celery("hello")
app.conf.update(
    mongodb_scheduler_db="my_project",
    mongodb_scheduler_url="mongodb://localhost:27017",
)
connect_from_app(app)

periodic = PeriodicTask(name="Send Email Notification", task="proj.notify_customers")
periodic.schedule = PeriodicTask.Crontab(minute="30", hour="7", day_of_week="1",
                           day_of_month="0", month_of_year="*")
periodic.save()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celerybeat_mongo2-0.2.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

celerybeat_mongo2-0.2.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file celerybeat_mongo2-0.2.1.tar.gz.

File metadata

  • Download URL: celerybeat_mongo2-0.2.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for celerybeat_mongo2-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f0df496950e60f10d136cf28af2cda60c76989dbe8ee378db7dfba8b106ac675
MD5 4ba4ac7000f138b095864ee8aeb470b9
BLAKE2b-256 b05a30b108eab8aa2afc8588e90077fa0ca3e36ae5db5e90f96afd9a0550b6ac

See more details on using hashes here.

File details

Details for the file celerybeat_mongo2-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for celerybeat_mongo2-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e90cb9705425cca3977720db576ecb9e7efc8f7568743b2b31a633e588e12bc
MD5 58e117ac14540c5100afcdebaa1ee021
BLAKE2b-256 f075f711b7e659a61722d8a2b34616e1c7900e5d91b5e7701cae3b57267dcad5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page