rpki.async.timer Class Reference

Inherits object.

List of all members.

Public Member Functions

def __cmp__
def __del__
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
def trace

Public Attributes

 errback
 handler
 when

Static Public Attributes

 gc_debug = False
 Verbose chatter about timers states and garbage collection.
list queue = []
 Timer queue, shared by all timer instances (there can be only one queue).
 run_debug = False
 Verbose chatter about timers being run.

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 80 of file async.py.


Member Function Documentation

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

Definition at line 138 of file async.py.

def rpki.async.timer.__del__ (   self  ) 

Definition at line 142 of file async.py.

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

Definition at line 107 of file async.py.

def rpki.async.timer.__repr__ (   self  ) 

Definition at line 204 of file async.py.

def rpki.async.timer.cancel (   self  ) 
Cancel a timer, if it was set.

Definition at line 145 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 229 of file async.py.

def rpki.async.timer.errback (   self,
  e 
)
Error callback.  May be overridden, or set with set_errback().

Definition at line 176 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 159 of file async.py.

def rpki.async.timer.is_set (   self  ) 
Test whether this timer is currently set.

Definition at line 155 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 188 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 208 of file async.py.

def rpki.async.timer.set (   self,
  when 
)
Set a timer.  Argument can be a datetime, to specify an absolute
time, or a timedelta, to specify an offset time.

Definition at line 123 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 183 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 166 of file async.py.

def rpki.async.timer.trace (   self,
  msg 
)
Debug logging.

Definition at line 115 of file async.py.


Member Data Documentation

Definition at line 185 of file async.py.

rpki::async.timer::gc_debug = False [static]

Verbose chatter about timers states and garbage collection.

Definition at line 97 of file async.py.

Definition at line 174 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 105 of file async.py.

rpki::async.timer::run_debug = False [static]

Verbose chatter about timers being run.

Definition at line 101 of file async.py.

Definition at line 112 of file async.py.


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

Generated on Tue Jan 12 07:56:02 2010 for RPKI Engine by  doxygen 1.6.1