From: Alexander Date: Fri, 27 Jan 2017 01:07:35 +0000 (+0300) Subject: cleanups for python3 X-Git-Tag: v4.5.0~15^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2acc2bd8283f22798422ee2313eaf4af7fc76c8;p=thirdparty%2Ftornado.git cleanups for python3 --- diff --git a/tornado/concurrent.py b/tornado/concurrent.py index 05205f737..e571a2dcb 100644 --- a/tornado/concurrent.py +++ b/tornado/concurrent.py @@ -234,7 +234,10 @@ class Future(object): if self._result is not None: return self._result if self._exc_info is not None: - raise_exc_info(self._exc_info) + try: + raise_exc_info(self._exc_info) + finally: + self = None self._check_done() return self._result diff --git a/tornado/gen.py b/tornado/gen.py index ec10c6ff3..14798ae2f 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -295,6 +295,7 @@ def _make_coroutine_wrapper(func, replace_callback): future.set_exc_info(sys.exc_info()) else: Runner(result, future, yielded) + yielded = None try: return future finally: @@ -1017,6 +1018,7 @@ class Runner(object): except Exception: self.had_exception = True exc_info = sys.exc_info() + future = None if exc_info is not None: try: @@ -1057,6 +1059,7 @@ class Runner(object): return if not self.handle_yield(yielded): return + yielded = None finally: self.running = False @@ -1105,8 +1108,11 @@ class Runner(object): self.future.set_exc_info(sys.exc_info()) if not self.future.done() or self.future is moment: + def inner(f): + f = None + self.run() self.io_loop.add_future( - self.future, lambda f: self.run()) + self.future, inner) return False return True diff --git a/tornado/http1connection.py b/tornado/http1connection.py index d0e91b827..d4f99c1cf 100644 --- a/tornado/http1connection.py +++ b/tornado/http1connection.py @@ -257,6 +257,7 @@ class HTTP1Connection(httputil.HTTPConnection): if need_delegate_close: with _ExceptionLoggingContext(app_log): delegate.on_connection_close() + header_future = None self._clear_callbacks() raise gen.Return(True) diff --git a/tornado/util.py b/tornado/util.py index 53584f98b..de0b2e5b0 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -171,7 +171,10 @@ def exec_in(code, glob, loc=None): if PY3: exec(""" def raise_exc_info(exc_info): - raise exc_info[1].with_traceback(exc_info[2]) + try: + raise exc_info[1].with_traceback(exc_info[2]) + finally: + exc_info = None def exec_in(code, glob, loc=None): if isinstance(code, str):