]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Remove "IOLoop is closing" error.
authorBen Darnell <ben@bendarnell.com>
Mon, 28 Sep 2015 00:10:49 +0000 (20:10 -0400)
committerBen Darnell <ben@bendarnell.com>
Mon, 28 Sep 2015 00:13:03 +0000 (20:13 -0400)
Callbacks added while the IOLoop is closing will now simply not be
called (which has always been a possible fate for callbacks added
just *before* the close). This exception has not proved to be very
useful and sometimes has false positives that are tricky to work around,
as seen in the linked issues.

Closes #1491.
Closes #1244.

tornado/ioloop.py

index a49e3ca955962cd9d8c5f3ad76ddb5fa6d94124d..195475ba061aec7b3a1800b665a79bf035f8f026 100644 (file)
@@ -914,7 +914,7 @@ class PollIOLoop(IOLoop):
             # with other threads, or waking logic will induce a race.
             with self._callback_lock:
                 if self._closing:
-                    raise RuntimeError("IOLoop is closing")
+                    return
                 list_empty = not self._callbacks
                 self._callbacks.append(functools.partial(
                     stack_context.wrap(callback), *args, **kwargs))
@@ -927,7 +927,7 @@ class PollIOLoop(IOLoop):
                     self._waker.wake()
         else:
             if self._closing:
-                raise RuntimeError("IOLoop is closing")
+                return
             # If we're on the IOLoop's thread, we don't need the lock,
             # since we don't need to wake anyone, just add the
             # callback. Blindly insert into self._callbacks. This is