Skip to content

An example of Dynamic Task Scheduling using the RedBeat python package, and Celery Beat.

License

Notifications You must be signed in to change notification settings

shonteag/redbeat-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CeleryBeat with RedBeatScheduler

A short example of how to run a RedBeatScheduler over CeleryBeat. It will require two terminal windows to run:

$ celery worker -A cluster -l info -P eventlet
$ celery beat -A cluster -l info

Then in a third window:

$ python
>>> import cluster
>>> from redbeat import RedBeatSchedulerEntry as Entry
>>> e = Entry('thingo', 'cluster.add_task', 10, args=[15, 4], app=cluster.app)
>>> e.save()
>>> key = e.key()

You should see log entries generated by the cluster.add_task method in your celery worker terminal. This indicates that it is working. You can also remove the task:

>>> import cluster
>>> from redbeat import RedBeatSchedulerEntry as Entry
>>> e = Entry.from_key(key)  # whatever the key was before
>>> e.delete()

and you should no longer see log entries (as the worker is no longer receiving tasks from the scheduler). Of course, you should have some method of keeping track of the keys for tasks you have scheduled, but I leave that to you (DB, file, etc).

Hope this helps somebody :)

About

An example of Dynamic Task Scheduling using the RedBeat python package, and Celery Beat.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages