From: Ben Darnell Date: Tue, 12 Oct 2010 00:02:15 +0000 (-0700) Subject: Run all IOStream callbacks inside a NullContext so that exception X-Git-Tag: v1.2.0~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ce6d3daeeeda0fc25206ef99048467307aa0cbe;p=thirdparty%2Ftornado.git Run all IOStream callbacks inside a NullContext so that exception handlers are run in the right order. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index 0a4fd8f75..ef1288b0a 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -177,7 +177,10 @@ class IOStream(object): def _run_callback(self, callback, *args, **kwargs): try: - callback(*args, **kwargs) + # Use a NullContext to ensure that all StackContexts are run + # inside our blanket exception handler rather than outside. + with stack_context.NullContext(): + callback(*args, **kwargs) except: logging.error("Uncaught exception, closing connection.", exc_info=True)