Skip to main content

A Celery Beat Scheduler using Redis for persistent storage

Project description

PyPI Actions Status ReadTheDocs Code style: black

RedisBeater is a Celery Beat Scheduler that stores the scheduled tasks and runtime metadata in Redis. It is a fork of RedBeat

Why RedisBeater?

  1. Dynamic live task creation and modification, without lengthy downtime

  2. Externally manage tasks from any language with Redis bindings

  3. Shared data store; Beat isn’t tied to a single drive or machine

  4. Fast startup even with a large task count

  5. Prevent accidentally running multiple Beat servers

  6. Work with any schedule class which provide required interface

For more background on the genesis of RedisBeater see this blog post

Getting Started

Install with pip:

pip install celery-redisbeater

Configure RedisBeater settings in your Celery configuration file:

redisbeater_redis_url = "redis://localhost:6379/1"

Then specify the scheduler when running Celery Beat:

celery beat -S redisbeater.RedisBeaterScheduler

RedisBeater uses a distributed lock to prevent multiple instances running. To disable this feature, set:

redisbeater_lock_key = None

More details available on Read the Docs

You can initialize and use RedisBeater just as use forked project. You just need to replace RedBeat with RedisBeater. For instance:

RedisBeaterSchedulerEntry(
    'task-name',
    'tasks.some_task',
    interval,
    args=['arg1', 2],
).save()

Custom Schedule

If you want to use your custom schedule class, you must define encode_beater method and return fields that your class needs when initialized by RedisBeaterScheduler later. For instance:

class customecrontab(BaseSchedule):
    def __init__(self, minute='*', hour='*', day_of_week='*',
             day_of_month='*', month_of_year='*', **kwargs):
    self.hour = hour
    self.minute = minute
    self.day_of_week = day_of_week
    self.day_of_month = day_of_month
    self.month_of_year = month_of_year
    super(crontab, self).__init__(**kwargs)

    def encode_beater(self):
        return {
            'minute': self.minute,
            'hour': self.hour,
            'day_of_week': self.day_of_week,
            'day_of_month': self.day_of_month,
            'month_of_year': self.month_of_year,
        }

Development

RedisBeater is available on GitHub

Once you have the source you can run the tests with the following commands:

pip install -r requirements.dev.txt
py.test tests

You can also quickly fire up a sample Beat instance with:

celery beat --config exampleconf

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

celery-redisbeater-1.0.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

celery_redisbeater-1.0.1-py2.py3-none-any.whl (15.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file celery-redisbeater-1.0.1.tar.gz.

File metadata

  • Download URL: celery-redisbeater-1.0.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for celery-redisbeater-1.0.1.tar.gz
Algorithm Hash digest
SHA256 17d7c023b7a2ae7b59fc6ddd0119197e8268fb669358ac6e8707778c11ba5522
MD5 14ccde15fe291b9af7f99460d7f1bd2a
BLAKE2b-256 bf10cde31e634f1c2ef7f0fa9611eaaa1244d9d0ef359b543c350dc73ba993c2

See more details on using hashes here.

File details

Details for the file celery_redisbeater-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: celery_redisbeater-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for celery_redisbeater-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bb43bf847b664c1458e35102be4d540a4d6fecac98cc98df4a9ec02abe48b278
MD5 3b68d2653a9131767c0b99a8eee6cfef
BLAKE2b-256 036b6f2d1ab0f0f56e327ee8d59e93aa800d5cac0be7733fe1e37e6a7e9da318

See more details on using hashes here.

Supported by

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