SingletonLockScheduler¶
- class beatdrop.schedulers.singleton_lock_scheduler.SingletonLockScheduler¶
- Bases: - Scheduler- Base singleton lock scheduler class. - This base class is used by scheduler where more that one can be started in parallel with - run, but only one should be checking entries and sending them. Uses a lock based approach to stop/tell other schedulers from running and sending tasks.- 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. 
- lock_timeout (datetime.timedelta) – The time a scheduler does not refresh the scheduler lock before it is considered dead. Should be at least 3 times the - max_interval.
 
 - 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.MethodNotImplementedError – - deletemethod 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:
- Raises:
- beatdrop.exceptions.MethodNotImplementedError – - getmethod not implemented.
 
 - list() Iterator[ScheduleEntry]¶
- List schedule entries. - Returns:
- List of schedule entries. 
- Return type:
- Iterator[ScheduleEntry] 
- Raises:
- beatdrop.exceptions.MethodNotImplementedError – - listmethod 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 - runmethod.
 
 - 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? - Falsewill not overwrite client read only fields.- Truewill. This should almost always be- False, unless you are a scheduler, or you know what you’re doing.
 
- Raises:
- beatdrop.exceptions.MethodNotImplementedError – - savemethod not implemented.
 
 - send(sched_entry: ScheduleEntry) None¶
- Send a schedule entry to the task backend. - This should be used by the - runmethod 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 - sendmethod 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 - sendmethod.