From 0126e2eaab7f81c2c2348d2ef00baeef62db8eb2 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Wed, 13 Feb 2013 22:52:17 -0500 Subject: [PATCH] Document and test the ability to call remove_timeout after it has fired. --- tornado/ioloop.py | 4 +++- tornado/test/ioloop_test.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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): -- 2.47.2