]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add missing return statements to call_at and call_later.
authorBen Darnell <ben@bendarnell.com>
Fri, 18 Jul 2014 03:33:34 +0000 (23:33 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 10 Aug 2014 18:13:03 +0000 (14:13 -0400)
Closes #1119.

tornado/ioloop.py
tornado/test/ioloop_test.py

index da9b7dbda599f139e9681150500ea56234d93cf8..738cc96440ecc60da71764c0e1801d0f23da8023 100644 (file)
@@ -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.
index e21d5d4c5b2a99344b53e3d005fa6d2b03d3d93e..8bf6ee2688d487e07ac05239e1d3b8697aa133ec 100644 (file)
@@ -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),