CeleryScheduler

class beatdrop.schedulers.celery_scheduler.CeleryScheduler

Bases: Scheduler

Implementation for sending celery tasks.

Combine as a second base class to be able to send tasks to Celery queues.

Example:

from beatdrop.schedulers import CeleryScheduler, SQLScheduler

class CelerySQLScheduler(SQLScheduler, CeleryScheduler):
    pass
Parameters:
  • max_interval (datetime.timedelta) – The maximum interval that the scheduler should sleep before waking up to check for due tasks.

  • sched_entry_types (Tuple[Type[ScheduleEntry]], default : (CrontabEntry, CrontabTZEntry, EventEntry, IntervalEntry)) – A list of valid schedule entry types for this scheduler. These are only stored in the scheduler, not externally.

  • default_sched_entries (List[ScheduleEntry], default : []) – Default list of schedule entries. In general these entries are not held in non-volatile storage so any metadata they hold will be lost if the scheduler fails. These entries are static. The keys cannot be overwritten or deleted.

  • celery_app (celery.Celery) – Celery app for sending tasks.

delete(sched_entry: ScheduleEntry) None

Delete a schedule entry from the scheduler.

Parameters:

sched_entry (ScheduleEntry) – Scheduler entry to delete from the scheduler.

Raises:

beatdrop.exceptions.MethodNotImplementedErrordelete method not implemented.

get(key: str) ScheduleEntry

Retrieve a schedule entry by its key.

Parameters:

key (str) – The schedule entry key.

Returns:

The schedule entry with the matching key.

Return type:

ScheduleEntry

Raises:

beatdrop.exceptions.MethodNotImplementedErrorget method not implemented.

list() Iterator[ScheduleEntry]

List schedule entries.

Returns:

List of schedule entries.

Return type:

Iterator[ScheduleEntry]

Raises:

beatdrop.exceptions.MethodNotImplementedErrorlist method not implemented.

run(max_iterations: int = None) None

Run the scheduler.

Parameters:

max_iterations (int) –

default : None

The maximum number of iterations to run the scheduler. None is unlimited.

Raises:

beatdrop.exceptions.MethodNotImplementedError – Must implement run method.

save(sched_entry: ScheduleEntry, client_read_only: bool = False) None

Save a new or update an existing schedule entry.

By default, read only attributes are not updated with save (suffixed with __).

Parameters:
  • sched_entry (ScheduleEntry) – Schedule entry to add or update in scheduler.

  • client_read_only (bool) – Overwrite client read only fields? False will not overwrite client read only fields. True will. This should almost always be False, unless you are a scheduler, or you know what you’re doing.

Raises:

beatdrop.exceptions.MethodNotImplementedErrorsave method not implemented.

send(sched_entry: ScheduleEntry) None

Send a schedule entry to the Celery queue.

Parameters:

sched_entry (ScheduleEntry) – Schedule entry to send to the Celery queue.