beat

The periodic task scheduler.

Module Contents

Classes

SchedulingError() An error occurred while scheduling a task.
ScheduleEntry(self,name=None,task=None,last_run_at=None,total_run_count=None,schedule=None,args=tuple,kwargs=dict,options=dict,relative=False,app=None) An entry in the scheduler.
Scheduler(self,app,schedule=None,max_interval=None,Producer=None,lazy=False,sync_every_tasks=None,**kwargs) Scheduler for periodic tasks.
PersistentScheduler(self,*args,**kwargs) Scheduler backed by shelve database.
Service(self,app,max_interval=None,schedule_filename=None,scheduler_cls=None) Celery periodic task service.
_Threaded(self,app,**kwargs) Embedded task scheduler using threading.
_Process(self,app,**kwargs)

Functions

EmbeddedService(app,max_interval=None,**kwargs) Return embedded clock service.
class SchedulingError

An error occurred while scheduling a task.

class ScheduleEntry(name=None, task=None, last_run_at=None, total_run_count=None, schedule=None, args=tuple, kwargs=dict, options=dict, relative=False, app=None)

An entry in the scheduler.

Arguments:
name (str): see name. schedule (~celery.schedules.schedule): see schedule. args (Tuple): see args. kwargs (Dict): see kwargs. options (Dict): see options. last_run_at (~datetime.datetime): see last_run_at. total_run_count (int): see total_run_count. relative (bool): Is the time relative to when the server starts?
__init__(name=None, task=None, last_run_at=None, total_run_count=None, schedule=None, args=tuple, kwargs=dict, options=dict, relative=False, app=None)
default_now()
_next_instance(last_run_at=None)

Return new instance, with date and count fields updated.

__reduce__()
update(other)

Update values from another entry.

Will only update “editable” fields:
task, schedule, args, kwargs, options.
is_due()

See is_due().

__iter__()
__repr__()
__lt__(other)
editable_fields_equal(other)
__eq__(other)

Test schedule entries equality.

Will only compare “editable” fields: task, schedule, args, kwargs, options.

__ne__(other)

Test schedule entries inequality.

Will only compare “editable” fields: task, schedule, args, kwargs, options.

class Scheduler(app, schedule=None, max_interval=None, Producer=None, lazy=False, sync_every_tasks=None, **kwargs)

Scheduler for periodic tasks.

The celery beat program may instantiate this class multiple times for introspection purposes, but then with the lazy argument set. It’s important for subclasses to be idempotent when this argument is set.

Arguments:
schedule (~celery.schedules.schedule): see schedule. max_interval (int): see max_interval. lazy (bool): Don’t set up the schedule.
__init__(app, schedule=None, max_interval=None, Producer=None, lazy=False, sync_every_tasks=None, **kwargs)
install_default_entries(data)
apply_entry(entry, producer=None)
adjust(n, drift=None)
is_due(entry)
_when(entry, next_time_to_run, mktime=None)
populate_heap(event_t=event_t, heapify=None)

Populate the heap with the data contained in the schedule.

tick(event_t=event_t, min=min, heappop=None, heappush=None)

Run a tick - one iteration of the scheduler.

Executes one due task per call.

Returns:
float: preferred delay in seconds for next call.
schedules_equal(old_schedules, new_schedules)
should_sync()
reserve(entry)
apply_async(entry, producer=None, advance=True, **kwargs)
send_task(*args, **kwargs)
setup_schedule()
_do_sync()
sync()
close()
add(**kwargs)
_maybe_entry(name, entry)
update_from_dict(dict_)
merge_inplace(b)
_ensure_connected()
get_schedule()
set_schedule(schedule)
connection()
producer()
info()
class PersistentScheduler(*args, **kwargs)

Scheduler backed by shelve database.

__init__(*args, **kwargs)
_remove_db()
_open_schedule()
_destroy_open_corrupted_schedule(exc)
setup_schedule()
_create_schedule()
get_schedule()
set_schedule(schedule)
sync()
close()
info()
class Service(app, max_interval=None, schedule_filename=None, scheduler_cls=None)

Celery periodic task service.

__init__(app, max_interval=None, schedule_filename=None, scheduler_cls=None)
__reduce__()
start(embedded_process=False)
sync()
stop(wait=False)
get_scheduler(lazy=False, extension_namespace="celery.beat_schedulers")
scheduler()
class _Threaded(app, **kwargs)

Embedded task scheduler using threading.

__init__(app, **kwargs)
run()
stop()
class _Process(app, **kwargs)
__init__(app, **kwargs)
run()
stop()
EmbeddedService(app, max_interval=None, **kwargs)

Return embedded clock service.

Arguments:
thread (bool): Run threaded instead of as a separate process.
Uses multiprocessing by default, if available.