diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2021-02-12 14:11:18 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-02-13 15:11:17 +1100 |
commit | 7ed99544e4cc1c09bd5abf9f54869c3122fa033b (patch) | |
tree | 768869bfd2e8950906a47d2a6d62d613e93ba60d /tests/extmod/uasyncio_current_task.py | |
parent | d128999938d6b44f52f4d0c6e1f5169ab3c1e7a5 (diff) | |
download | micropython-7ed99544e4cc1c09bd5abf9f54869c3122fa033b.tar.gz micropython-7ed99544e4cc1c09bd5abf9f54869c3122fa033b.zip |
extmod/uasyncio: Add asyncio.current_task().
Matches CPython behavior.
Fixes #6686
Diffstat (limited to 'tests/extmod/uasyncio_current_task.py')
-rw-r--r-- | tests/extmod/uasyncio_current_task.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/extmod/uasyncio_current_task.py b/tests/extmod/uasyncio_current_task.py new file mode 100644 index 0000000000..3165a2cf16 --- /dev/null +++ b/tests/extmod/uasyncio_current_task.py @@ -0,0 +1,25 @@ +# Test current_task() function + +try: + import uasyncio as asyncio +except ImportError: + try: + import asyncio + except ImportError: + print("SKIP") + raise SystemExit + + +async def task(result): + result[0] = asyncio.current_task() + + +async def main(): + result = [None] + t = asyncio.create_task(task(result)) + await asyncio.sleep(0) + await asyncio.sleep(0) + print(t is result[0]) + + +asyncio.run(main()) |