From ef137327f8914ec709b8852c0042c74959d6bc9f Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Tue, 14 Jul 2009 00:19:01 -0700 Subject: [PATCH] Made more things inherit from object in api, cleaned up some doc bugs. --- eventlet/api.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/eventlet/api.py b/eventlet/api.py index 0cc2856..13637b7 100644 --- a/eventlet/api.py +++ b/eventlet/api.py @@ -308,20 +308,28 @@ call_after = call_after_local class _SilentException: pass -class FakeTimer: - +class FakeTimer(object): def cancel(self): pass -class timeout: +class timeout(object): """Raise an exception in the block after timeout. + + Example:: - with timeout(seconds[, exc]): - ... code block ... + with timeout(10): + urllib2.open('http://example.com') Assuming code block is yielding (i.e. gives up control to the hub), - an exception provided in `exc' argument will be raised - (TimeoutError if `exc' is omitted). + an exception provided in 'exc' argument will be raised + (TimeoutError if 'exc' is omitted):: + + try: + with timeout(10, MySpecialError, error_arg_1): + urllib2.open('http://example.com') + except MySpecialError, e: + print "special error received" + When exc is None, code block is interrupted silently. """ @@ -498,7 +506,6 @@ def sleep(seconds=0): getcurrent = greenlet.getcurrent GreenletExit = greenlet.GreenletExit - class Spew(object): """ """