Skip to content

Commit

Permalink
Document and test the ability to call remove_timeout after it has fired.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Feb 14, 2013
1 parent 7327cde commit 0126e2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tornado/ioloop.py
Expand Up @@ -319,7 +319,9 @@ def add_timeout(self, deadline, callback):
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()

Expand Down
6 changes: 6 additions & 0 deletions tornado/test/ioloop_test.py
Expand Up @@ -148,6 +148,12 @@ def handler(fd, events):
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):
Expand Down

0 comments on commit 0126e2e

Please sign in to comment.