From: Ben Darnell Date: Mon, 15 Sep 2014 02:38:14 +0000 (-0400) Subject: Capture stack context in gen.engine's wrapper function. X-Git-Tag: v4.1.0b1~90^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f40d39b;p=thirdparty%2Ftornado.git Capture stack context in gen.engine's wrapper function. This was an error that went unnoticed in earlier versions because Futures passed through exceptions in their callbacks. --- diff --git a/tornado/gen.py b/tornado/gen.py index 4bb82d422..d0d0b5ef2 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -109,7 +109,10 @@ def engine(func): raise ReturnValueIgnoredError( "@gen.engine functions cannot return values: %r" % (future.result(),)) - future.add_done_callback(final_callback) + # The engine interface doesn't give us any way to return + # errors but to raise them into the stack context. + # Save the stack context here to use when the Future has resolved. + future.add_done_callback(stack_context.wrap(final_callback)) return wrapper