MemScheduler

class beatdrop.schedulers.mem_scheduler.MemScheduler

Bases: Scheduler

Static in memory scheduler.

This scheduler does not implement the send method. This must be implemented before it can actually send tasks to the specified backend.

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.

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() 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.

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 task backend.

This should be used by the run method when a schedule is due. Subclasses can override this for common schedulers without changing the specifics of how a schedule runs. Send it to a queue, to celery etc.

NOTE: for the reasons above the send method should not perform any actions against the state of the scheduler or schedule entries.

Parameters:

sched_entry (ScheduleEntry) – Schedule entry that will be sent to the task backend.

Raises:

beatdrop.exceptions.MethodNotImplementedError – Must implement send method.