From 6e8a137e6824716531d749bce8a18a1f229ed873 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 21 Jan 2018 20:12:06 -0500 Subject: [PATCH] concurrent: Fix importability of tornado.wsgi on app engine --- tornado/concurrent.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tornado/concurrent.py b/tornado/concurrent.py index cca6468c..65da0ac8 100644 --- a/tornado/concurrent.py +++ b/tornado/concurrent.py @@ -337,11 +337,12 @@ class Future(object): def _set_done(self): self._done = True - from tornado.ioloop import IOLoop - loop = IOLoop.current() - for cb in self._callbacks: - loop.add_callback(cb, self) - self._callbacks = None + if self._callbacks: + from tornado.ioloop import IOLoop + loop = IOLoop.current() + for cb in self._callbacks: + loop.add_callback(cb, self) + self._callbacks = None # On Python 3.3 or older, objects with a destructor part of a reference # cycle are never destroyed. It's no longer the case on Python 3.4 thanks to