From: Ben Darnell Date: Fri, 18 Jul 2014 03:33:34 +0000 (-0400) Subject: Add missing return statements to call_at and call_later. X-Git-Tag: v4.0.1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7550e8bb55c7a9e7f3fd68918d0a91ce845d36f4;p=thirdparty%2Ftornado.git Add missing return statements to call_at and call_later. Closes #1119. --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index da9b7dbda..738cc9644 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -477,7 +477,7 @@ class IOLoop(Configurable): .. versionadded:: 4.0 """ - self.call_at(self.time() + delay, callback, *args, **kwargs) + return self.call_at(self.time() + delay, callback, *args, **kwargs) def call_at(self, when, callback, *args, **kwargs): """Runs the ``callback`` at the absolute time designated by ``when``. @@ -493,7 +493,7 @@ class IOLoop(Configurable): .. versionadded:: 4.0 """ - self.add_timeout(when, callback, *args, **kwargs) + return self.add_timeout(when, callback, *args, **kwargs) def remove_timeout(self, timeout): """Cancels a pending timeout. diff --git a/tornado/test/ioloop_test.py b/tornado/test/ioloop_test.py index e21d5d4c5..8bf6ee268 100644 --- a/tornado/test/ioloop_test.py +++ b/tornado/test/ioloop_test.py @@ -185,6 +185,23 @@ class TestIOLoop(AsyncTestCase): self.wait() self.assertEqual(results, [1, 2, 3, 4]) + def test_add_timeout_return(self): + # All the timeout methods return non-None handles that can be + # passed to remove_timeout. + handle = self.io_loop.add_timeout(self.io_loop.time(), lambda: None) + self.assertFalse(handle is None) + self.io_loop.remove_timeout(handle) + + def test_call_at_return(self): + handle = self.io_loop.call_at(self.io_loop.time(), lambda: None) + self.assertFalse(handle is None) + self.io_loop.remove_timeout(handle) + + def test_call_later_return(self): + handle = self.io_loop.call_later(0, lambda: None) + self.assertFalse(handle is None) + self.io_loop.remove_timeout(handle) + def test_close_file_object(self): """When a file object is used instead of a numeric file descriptor, the object should be closed (by IOLoop.close(all_fds=True),