10000 update sched to 3.13.3 · arihant2math/RustPython@1c64bde · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c64bde

Browse files
committed
update sched to 3.13.3
1 parent 70f3aec commit 1c64bde

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

Lib/sched.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
implement simulated time by writing your own functions. This can
1212
also be used to integrate scheduling with STDWIN events; the delay
1313
function is allowed to modify the queue. Time can be expressed as
14-
integers or floating point numbers, as long as it is consistent.
14+
integers or floating-point numbers, as long as it is consistent.
1515
1616
Events are specified by tuples (time, priority, action, argument, kwargs).
1717
As in UNIX, lower priority numbers mean higher priority; in this

Lib/test/test_sched.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_enterabs(self):
5858
scheduler.run()
5959
self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
6060

61+
@threading_helper.requires_working_threading()
6162
def test_enter_concurrent(self):
6263
q = queue.Queue()
6364
fun = q.put
@@ -91,10 +92,23 @@ def test_priority(self):
9192
l = []
9293
fun = lambda x: l.append(x)
9394
scheduler = sched.scheduler(time.time, time.sleep)
94-
for priority in [1, 2, 3, 4, 5]:
95-
z = scheduler.enterabs(0.01, priority, fun, (priority,))
96-
scheduler.run()
97-
self.assertEqual(l, [1, 2, 3, 4, 5])
95+
96+
cases = [
97+
([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]),
98+
([5, 4, 3, 2, 1], [1, 2, 3, 4, 5]),
99+
([2, 5, 3, 1, 4], [1, 2, 3, 4, 5]),
100+
([1, 2, 3, 2, 1], [1, 1, 2, 2, 3]),
101+
]
102+
for priorities, expected in cases:
103+
with self.subTest(priorities=priorities, expected=expected):
104+
for priority in priorities:
105+
scheduler.enterabs(0.01, priority, fun, (priority,))
106+
scheduler.run()
107+
self.assertEqual(l, expected)
108+
109+
# Cleanup:
110+
self.assertTrue(scheduler.empty())
111+
l.clear()
98112

99113
def test_cancel(self):
100114
l = []
@@ -111,6 +125,7 @@ def test_cancel(self):
111125
scheduler.run()
112126
self.assertEqual(l, [0.02, 0.03, 0.04])
113127

128+
@threading_helper.requires_working_threading()
114129
def test_cancel_concurrent(self):
115130
q = queue.Queue()
116131
fun = q.put

0 commit comments

Comments
 (0)
0