update sched to 3.13.3

This commit is contained in:
Ashwin Naren committed 2025-04-21 21:11:42 -07:00
1 parent 70f3aec552
commit 1c64bde0ee
2 files changed
+20 -5

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ substituting time and sleep from built-in module time, or you can
implement simulated time by writing your own functions. This can
also be used to integrate scheduling with STDWIN events; the delay
function is allowed to modify the queue. Time can be expressed as
integers or floating point numbers, as long as it is consistent.
integers or floating-point numbers, as long as it is consistent.
Events are specified by tuples (time, priority, action, argument, kwargs).
As in UNIX, lower priority numbers mean higher priority; in this
+19 -4
View File
@@ -58,6 +58,7 @@ class TestCase(unittest.TestCase):
scheduler.run()
self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
@threading_helper.requires_working_threading()
def test_enter_concurrent(self):
q = queue.Queue()
fun = q.put
@@ -91,10 +92,23 @@ class TestCase(unittest.TestCase):
l = []
fun = lambda x: l.append(x)
scheduler = sched.scheduler(time.time, time.sleep)
for priority in [1, 2, 3, 4, 5]:
z = scheduler.enterabs(0.01, priority, fun, (priority,))
scheduler.run()
self.assertEqual(l, [1, 2, 3, 4, 5])
cases = [
([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]),
([5, 4, 3, 2, 1], [1, 2, 3, 4, 5]),
([2, 5, 3, 1, 4], [1, 2, 3, 4, 5]),
([1, 2, 3, 2, 1], [1, 1, 2, 2, 3]),
]
for priorities, expected in cases:
with self.subTest(priorities=priorities, expected=expected):
for priority in priorities:
scheduler.enterabs(0.01, priority, fun, (priority,))
scheduler.run()
self.assertEqual(l, expected)
# Cleanup:
self.assertTrue(scheduler.empty())
l.clear()
def test_cancel(self):
l = []
@@ -111,6 +125,7 @@ class TestCase(unittest.TestCase):
scheduler.run()
self.assertEqual(l, [0.02, 0.03, 0.04])
@threading_helper.requires_working_threading()
def test_cancel_concurrent(self):
q = queue.Queue()
fun = q.put