forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 3
サンプル Asyncio
TakeoTakahashi2020 edited this page Sep 23, 2021
·
2 revisions
- EK-RA6M2ボードでは、CPython 3.8 Asyncioサブセット機能が使用できます。
- 3つのインスタンスでそれぞれカウントした値を表示します。
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())
- asyncio機能の詳細は、以下のurlを参照ください