MCPcopy
hub / github.com/tornadoweb/tornado / test_add_callback_wakeup

Method test_add_callback_wakeup

tornado/test/ioloop_test.py:60–76  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

58 self.assertLess(self.calls, 10)
59
60 def test_add_callback_wakeup(self):
61 # Make sure that add_callback from inside a running IOLoop
62 # wakes up the IOLoop immediately instead of waiting for a timeout.
63 def callback():
64 self.called = True
65 self.stop()
66
67 def schedule_callback():
68 self.called = False
69 self.io_loop.add_callback(callback)
70 # Store away the time so we can check if we woke up immediately
71 self.start_time = time.time()
72
73 self.io_loop.add_timeout(self.io_loop.time(), schedule_callback)
74 self.wait()
75 self.assertAlmostEqual(time.time(), self.start_time, places=2)
76 self.assertTrue(self.called)
77
78 def test_add_callback_wakeup_other_thread(self):
79 def target():

Callers

nothing calls this directly

Calls 3

add_timeoutMethod · 0.80
timeMethod · 0.80
waitMethod · 0.45

Tested by

no test coverage detected