forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 3
Sample Asyncio
TakeoTakahashi2020 edited this page Sep 23, 2021
·
2 revisions
- For the EK-RA6M2 board, CPython 3.8 Asyncio subset feature can be used.
- Three instances are independently created, count every 1s.
import uasyncio as asyncio
async def bar(x):
count = 0
while True:
count += 1
print('Instance: {} count: {}'.format(x, count))
await asyncio.sleep(1) # Pause 1s
async def main():
for x in range(3):
asyncio.create_task(bar(x))
await asyncio.sleep(10)
asyncio.run(main())
- For details on the asyncio function, refer to the following url.