We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aba6935 commit 48ead94Copy full SHA for 48ead94
uasyncio.core/test_fair_schedule.py
@@ -0,0 +1,34 @@
1
+# Test that uasyncio scheduling is fair, i.e. gives all
2
+# coroutines equal chance to run (this specifically checks
3
+# round-robin scheduling).
4
+import uasyncio.core as asyncio
5
+
6
7
+COROS = 5
8
+ITERS = 5
9
10
11
+result = []
12
13
14
+async def coro(n):
15
+ for i in range(ITERS):
16
+ result.append(n)
17
+ yield
18
19
20
+async def done():
21
+ while True:
22
+ if len(result) == COROS * ITERS:
23
+ #print(result)
24
+ assert result == list(range(COROS)) * ITERS
25
+ return
26
27
28
29
+loop = asyncio.get_event_loop()
30
31
+for n in range(COROS):
32
+ loop.create_task(coro(n))
33
34
+loop.run_until_complete(done())
0 commit comments