tests: Rename uasyncio to asyncio.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
2fbc08c462
commit
6027c41c8f
33
tests/extmod/asyncio_new_event_loop.py
Normal file
33
tests/extmod/asyncio_new_event_loop.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Test Loop.new_event_loop()
|
||||
|
||||
try:
|
||||
import asyncio
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
||||
async def task():
|
||||
for i in range(4):
|
||||
print("task", i)
|
||||
await asyncio.sleep(0)
|
||||
await asyncio.sleep(0)
|
||||
|
||||
|
||||
async def main():
|
||||
print("start")
|
||||
loop.create_task(task())
|
||||
await asyncio.sleep(0)
|
||||
print("stop")
|
||||
loop.stop()
|
||||
|
||||
|
||||
# Use default event loop to run some tasks
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.create_task(main())
|
||||
loop.run_forever()
|
||||
|
||||
# Create new event loop, old one should not keep running
|
||||
loop = asyncio.new_event_loop()
|
||||
loop.create_task(main())
|
||||
loop.run_forever()
|
||||
Reference in New Issue
Block a user