diff --git a/greentest/test__api_timeout.py b/greentest/test__api_timeout.py index 5355950..ad3d93d 100644 --- a/greentest/test__api_timeout.py +++ b/greentest/test__api_timeout.py @@ -35,6 +35,20 @@ class Test(unittest.TestCase): except ValueError: pass + # basically, anything that greenlet.throw accepts work: + try: + 1/0 + except: + try: + with timeout(DELAY, *sys.exc_info()): + sleep(DELAY*2) + assert 'should not get there' + assert 'should not get there' + except ZeroDivisionError: + pass + else: + assert 'should not get there' + # It's possible to cancel the timer inside the block: with timeout(DELAY) as timer: timer.cancel()