rpki.async.timer Class Reference
Inherits object.
List of all members.
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 | |
|
) |
| | |
def rpki.async.timer.__del__ |
( |
|
self |
) |
|
def rpki.async.timer.__init__ |
( |
|
self, |
|
|
|
handler = None , |
|
|
|
errback = None | |
|
) |
| | |
def rpki.async.timer.__repr__ |
( |
|
self |
) |
|
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.
Error callback. May be overridden, or set with set_errback().
Definition at line 176 of file async.py.
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 | |
|
) |
| | |
Member Data Documentation
Verbose chatter about timers states and garbage collection.
Definition at line 97 of file async.py.
Timer queue, shared by all timer instances (there can be only one queue).
Definition at line 105 of file async.py.
Verbose chatter about timers being run.
Definition at line 101 of file async.py.
The documentation for this class was generated from the following file: