scheduler¶
Scheduler for and executing PlateFlo perfusion system events.
- plateflo.scheduler.DailyEvent(task, hh=0, mm=0, s=0, args=[], **kwargs)¶
Wrapper around
RecurringEvent
for convenient daily task execution.- Parameters:
hh (int) – Time of day, hour [0-23]
mm (int, default = 0) – Time of day, minute [0-59]
s (int, default = 0) – Time of day, seconds [0-59]
task (function pointer) – Function executed at scheduled time
args (list) – Add positional arguments passed to task
kwargs – Additional keyword arguments passed to task
- Returns:
Daily recurring event.
- Return type:
- class plateflo.scheduler.RecurringEvent(interval, task, start_time=None, stop_time=None, delay=None, _eventID=None, _resched=False, args=[], **kwargs)¶
Event triggered at the specified interval w/ optional start time OR delay.
- Parameters:
interval (timedelta) – Recurrance interval
task (function pointer) – Function to excute at scheduled interval
start_time (datetime, optional) – First occurance at specified time. Excludes delay
stop_time (datetime, optional) – Terminate recurrance after this time
delay (timedelta, optional) – Delay first occurance by this amount. Excludes start_time
args (list) – Positional arguments, passed to task
**kwargs – Keyword arguments, passed to task
- Raises:
ValueError – both start_time and delay parameters are provided. task function not provided
TypeError – interval not of type timedelta
- class plateflo.scheduler.Scheduler¶
Event schedule handler. Schedules, monitors, and executes events
- events¶
Unexecuted future event objects.
- Type:
list
- event_history¶
Previous triggered event objects.
- Type:
list
- add_event(event)¶
Inserts scheduled event into the event queue.
- Parameters:
event (SingleEvent, RecurringEvent) –
SingleEvent
orRecurringEvent
object- Returns:
Event identifier. Can be used to remove event with
remove_event()
- Return type:
int
- monitor()¶
Call frequently from the main script loop!
Checks if events are due to trigger and transfers triggered events to the event history. Reschedules recurring events if necessary.
- remove_event(eventID)¶
Removes the selected event from the scheduler queue.
- Parameters:
eventID (int) – Unique event identifier.
- class plateflo.scheduler.SingleEvent(dateTime, task, _eventID=None, args=[], **kwargs)¶
Simple event object, executes once at the specified time.
- Parameters:
dateTime (datetime) – Scheduled execution start time
task (function pointer) – Function to excecute at scheduled time
args (list) – positional arguments, passed to task
**kwargs – keyword arguments passed to task
- trigger()¶
Execute the event task.