From: Ben Darnell Date: Thu, 14 Feb 2013 03:52:17 +0000 (-0500) Subject: Document and test the ability to call remove_timeout after it has fired. X-Git-Tag: v3.0.0~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0126e2eaab7f81c2c2348d2ef00baeef62db8eb2;p=thirdparty%2Ftornado.git Document and test the ability to call remove_timeout after it has fired. --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index e81476b64..4062661b2 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -319,7 +319,9 @@ class IOLoop(Configurable): def remove_timeout(self, timeout): """Cancels a pending timeout. - The argument is a handle as returned by add_timeout. + The argument is a handle as returned by add_timeout. It is + safe to call `remove_timeout` even if the callback has already + been run. """ raise NotImplementedError() diff --git a/tornado/test/ioloop_test.py b/tornado/test/ioloop_test.py index 08fb19831..a395cde71 100644 --- a/tornado/test/ioloop_test.py +++ b/tornado/test/ioloop_test.py @@ -148,6 +148,12 @@ class TestIOLoop(AsyncTestCase): client.close() server.close() + def test_remove_timeout_after_fire(self): + # It is not an error to call remove_timeout after it has run. + handle = self.io_loop.add_timeout(self.io_loop.time(), self.stop()) + self.wait() + self.io_loop.remove_timeout(handle) + class TestIOLoopAddCallback(AsyncTestCase): def setUp(self):