mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
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:
parent
73520d57eb
commit
556ba04a8d
5 changed files with 34 additions and 4 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue