]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Document and test the ability to call remove_timeout after it has fired.
authorBen Darnell <ben@bendarnell.com>
Thu, 14 Feb 2013 03:52:17 +0000 (22:52 -0500)
committerBen Darnell <ben@bendarnell.com>
Thu, 14 Feb 2013 03:52:17 +0000 (22:52 -0500)
tornado/ioloop.py
tornado/test/ioloop_test.py

index e81476b649a290b128cfc9631dfa30816c23a9bf..4062661b2ab550c68625fe8611134398247fd089 100644 (file)
@@ -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()
 
index 08fb1983108fdd52d6e45f21177d34272e9fa7a1..a395cde719cc7b10b1f0ab3745d9a50995dcdb68 100644 (file)
@@ -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):