extmod/asyncio: Make current_task raise exception when there is no task.

Matches CPython behaviour.

Fixes issue #11530.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-02-26 10:52:12 +11:00
parent 8fdcc25eb0
commit 8692d2602a
2 changed files with 16 additions and 0 deletions

View File

@@ -19,4 +19,15 @@ async def main():
print(t is result[0])
try:
print(asyncio.current_task())
except RuntimeError:
print("RuntimeError")
asyncio.run(main())
try:
print(asyncio.current_task())
except RuntimeError:
print("RuntimeError")