aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki/async.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2010-04-12 23:07:16 +0000
committerRob Austein <sra@hactrn.net>2010-04-12 23:07:16 +0000
commit41c51dee21554e6ff668a399bdc1c72df9173722 (patch)
tree40de5869473a0b252bc63c719b5cf796386b11e9 /rpkid/rpki/async.py
parent32c6fe7a8786a4d6393b4d05f423deb4594f377d (diff)
Lint
svn path=/myrpki/myrpki.py; revision=3191
Diffstat (limited to 'rpkid/rpki/async.py')
-rw-r--r--rpkid/rpki/async.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/rpkid/rpki/async.py b/rpkid/rpki/async.py
index 758a437a..fc6ba663 100644
--- a/rpkid/rpki/async.py
+++ b/rpkid/rpki/async.py
@@ -68,15 +68,17 @@ class iterator(object):
self.doit()
def doit(self):
+ """
+ Implement the iterator protocol: attempt to call the item handler
+ with the next iteration value, call the termination handler if the
+ iterator signaled StopIteration.
+ """
try:
self.item_callback(self, self.iterator.next())
except StopIteration:
if self.done_callback is not None:
self.done_callback()
- def ignore(self, ignored):
- self()
-
class timer(object):
"""
Timer construct for event-driven code. It can be used in either of two ways:
@@ -319,10 +321,18 @@ class sync_wrapper(object):
self.func = func
def cb(self, res = None):
+ """
+ Wrapped code has requested normal termination. Store result, and
+ exit the event loop.
+ """
self.res = res
raise ExitNow
def eb(self, err):
+ """
+ Wrapped code raised an exception. Store exception data, then exit
+ the event loop.
+ """
exc_info = sys.exc_info()
self.err = exc_info if exc_info[1] is err else err
raise ExitNow
@@ -330,6 +340,10 @@ class sync_wrapper(object):
def __call__(self, *args, **kwargs):
def thunk():
+ """
+ Deferred action to call the wrapped code once event system is
+ running.
+ """
try:
self.func(self.cb, self.eb, *args, **kwargs)
except ExitNow:
@@ -365,6 +379,9 @@ class gc_summary(object):
self.timer.set(self.interval)
def handler(self):
+ """
+ Collect and log GC state for this period, reset timer.
+ """
rpki.log.debug("gc_summary: Running gc.collect()")
gc.collect()
rpki.log.debug("gc_summary: Summarizing (threshold %d)" % self.threshold)