rpki.async.timer Class Reference

Inherits object.

List of all members.

Public Member Functions

def __cmp__
def __init__
def __repr__
def cancel
def clear
def errback
def handler
def is_set
def runq
def seconds_until_wakeup
def set
def set_errback
def set_handler

Public Attributes

 errback
 handler
 when

Static Public Attributes

list queue = []
 Timer queue, shared by all timer instances (there can be only one queue).


Detailed Description

Timer construct for event-driven code.  It can be used in either of two ways:

- As a virtual class, in which case the subclass should provide a
  handler() method to receive the wakup event when the timer expires; or

- By setting an explicit handler callback, either via the
  constructor or the set_handler() method.

Subclassing is probably more Pythonic, but setting an explict
handler turns out to be very convenient when combined with bound
methods to other objects.

Definition at line 77 of file async.py.


Member Function Documentation

def rpki.async.timer.__cmp__ (   self,
  other 
)

Definition at line 121 of file async.py.

def rpki.async.timer.__init__ (   self,
  handler = None,
  errback = None 
)

Definition at line 97 of file async.py.

def rpki.async.timer.__repr__ (   self  ) 

Definition at line 180 of file async.py.

def rpki.async.timer.cancel (   self  ) 

Cancel a timer, if it was set.

Definition at line 124 of file async.py.

def rpki.async.timer.clear (   cls  ) 

Cancel every timer on the queue.  We could just throw away the
queue content, but this way we can notify subclasses that provide
their own cancel() method.

Definition at line 206 of file async.py.

def rpki.async.timer.errback (   self,
  e 
)

Error callback.  May be overridden, or set with set_errback().

Definition at line 154 of file async.py.

def rpki.async.timer.handler (   self  ) 

Handle a timer that has expired.  This must either be overriden by
a subclass or set dynamically by set_handler().

Definition at line 137 of file async.py.

def rpki.async.timer.is_set (   self  ) 

Test whether this timer is currently set.

Definition at line 133 of file async.py.

def rpki.async.timer.runq (   cls  ) 

Run the timer queue: for each timer whose call time has passed,
pull the timer off the queue and call its handler() method.

Definition at line 166 of file async.py.

def rpki.async.timer.seconds_until_wakeup (   cls  ) 

Calculate delay until next timer expires, or None if no timers are
set and we should wait indefinitely.  Rounds up to avoid spinning
in select() or poll().  We could calculate fractional seconds in
the right units instead, but select() and poll() don't even take
the same units (argh!), and we're not doing anything that
hair-triggered, so rounding up is simplest.

Definition at line 184 of file async.py.

def rpki.async.timer.set (   self,
  when 
)

Set a timer.  Argument can be a datetime, to specify an absolute
time, a timedelta, to specify an offset time, or None, to indicate
that the timer should expire immediately, which can be useful in
avoiding an excessively deep call stack.

Definition at line 103 of file async.py.

def rpki.async.timer.set_errback (   self,
  errback 
)

Set a timer's errback.  Like set_handler(), for errbacks.

Definition at line 161 of file async.py.

def rpki.async.timer.set_handler (   self,
  handler 
)

Set timer's expiration handler.  This is an alternative to
subclassing the timer class, and may be easier to use when
integrating timers into other classes (eg, the handler can be a
bound method to an object in a class representing a network
connection).

Definition at line 144 of file async.py.


Member Data Documentation

Definition at line 163 of file async.py.

Definition at line 152 of file async.py.

rpki::async.timer::queue = [] [static]

Timer queue, shared by all timer instances (there can be only one queue).

Definition at line 95 of file async.py.

Definition at line 111 of file async.py.


The documentation for this class was generated from the following file:

Generated on Tue Jun 2 19:10:19 2009 for RPKI Engine by  doxygen 1.5.8