Package flumotion :: Package component :: Package base :: Module scheduler :: Class Scheduler
[hide private]

Class Scheduler

source code

extern.log.log.Loggable --+
                          |
                         Scheduler
Known Subclasses:

I provide notifications when events start and end. I use a eventcalendar.Calendar for scheduling.

Instance Methods [hide private]
 
__init__(self) source code
eventcalendar.Calendar
getCalendar(self)
Return the calendar used for scheduling.
source code
 
setCalendar(self, calendar, when=None)
Set the given calendar to use for scheduling.
source code
 
getPoints(self, when=None)
Get all points on this scheduler's event horizon.
source code
 
cleanup(self)
Clean up all resources used by this scheduler.
source code
int
subscribe(self, eventInstanceStarted, eventInstanceEnded)
Subscribe to event happenings in the scheduler.
source code
 
unsubscribe(self, id)
Unsubscribe from event happenings in the scheduler.
source code
 
_eventInstanceStarted(self, eventInstance) source code
 
_eventInstanceEnded(self, eventInstance) source code
 
_reschedule(self) source code
 
_cancelScheduledCalls(self) source code

Inherited from extern.log.log.Loggable: __providedBy__, __provides__, debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure, writeMarker

Class Variables [hide private]
datetime.timedelta windowSize = datetime.timedelta(1)
how much time to look ahead when scheduling

Inherited from extern.log.log.Loggable: __implemented__, logCategory

Method Details [hide private]

setCalendar(self, calendar, when=None)

source code 

Set the given calendar to use for scheduling.

This function will send start notifications for all new events that should currently be in progress, if they were not registered in the old calendar or if there was no old calendar.

If the scheduler previously had a calendar, it will send end notifications for all events currently in progress that are not in the new calendar.

Parameters:
  • calendar (eventcalendar.Calendar) - the new calendar to set
  • when (datetime.datetime) - the time at which to consider the calendar to be set; defaults to now

cleanup(self)

source code 

Clean up all resources used by this scheduler.

This cancels all pending scheduling calls.

subscribe(self, eventInstanceStarted, eventInstanceEnded)

source code 

Subscribe to event happenings in the scheduler.

Parameters:
  • eventInstanceStarted (function with signature EventInstance) - function that will be called when an event instance starts
  • eventInstanceEnded (function with signature EventInstance) - function that will be called when an event instance ends
Returns: int
A subscription ID that can later be passed to unsubscribe().

unsubscribe(self, id)

source code 

Unsubscribe from event happenings in the scheduler.

Parameters:
  • id (int) - Subscription ID received from subscribe()