Fix #13449: add 'blocking' parameter to sched.scheduler.run() so that the scheduler can be used in non-blocking applications

This commit is contained in:
Giampaolo Rodola' 2011-12-14 14:38:45 +01:00
parent 73520d57eb
commit 556ba04a8d
5 changed files with 34 additions and 4 deletions

View file

@ -86,6 +86,16 @@ class TestCase(unittest.TestCase):
scheduler.run()
self.assertEqual(flag, [None])
def test_run_non_blocking(self):
l = []
fun = lambda x: l.append(x)
scheduler = sched.scheduler(time.time, time.sleep)
for x in [10, 9, 8, 7, 6]:
scheduler.enter(x, 1, fun, (x,))
scheduler.run(blocking=False)
self.assertEqual(l, [])
def test_main():
support.run_unittest(TestCase)