From: Mark Wooding Date: Sat, 15 May 2010 18:42:08 +0000 (+0100) Subject: py/rmcr.py: Handle stray exceptions from coroutines more sensibly. X-Git-Tag: 1.0.0pre8.1~1 X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/commitdiff_plain/6a2ebadbabb3b67b88cd80cea1545f89cedadf0a py/rmcr.py: Handle stray exceptions from coroutines more sensibly. With a little luck this means that they won't just vanish silently. --- diff --git a/py/rmcr.py b/py/rmcr.py index f73a6cc9..70df8f3a 100644 --- a/py/rmcr.py +++ b/py/rmcr.py @@ -29,7 +29,7 @@ __pychecker__ = 'self=me' ### External dependencies. import thread as T -from sys import exc_info +from sys import exc_info, excepthook ###-------------------------------------------------------------------------- ### What's going on? @@ -134,11 +134,11 @@ class Coroutine (object): try: _debug(' _start(%s): call user (args = %s, kwargs = %s)' % (me, args, kwargs)) - me._func(*args, **kwargs) + me._onexit = [me._func(*args, **kwargs), None] except: exc = exc_info() _debug(' _start(%s): caught exception (%s)' % (me, exc)) - _switchto(findvictim(me.parent), None, exc) + me._onexit = [None, exc] finally: _debug(' _start(%s): finally' % me) _debug(' _start(%s): _onexit = %s' % (me, me._onexit))