Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
7ed99544
Commit
7ed99544
authored
Feb 12, 2021
by
Jim Mussared
Committed by
Damien George
Feb 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extmod/uasyncio: Add asyncio.current_task().
Matches CPython behavior. Fixes #6686
parent
d1289999
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
docs/library/uasyncio.rst
docs/library/uasyncio.rst
+4
-0
extmod/uasyncio/core.py
extmod/uasyncio/core.py
+4
-0
tests/extmod/uasyncio_current_task.py
tests/extmod/uasyncio_current_task.py
+25
-0
tests/extmod/uasyncio_current_task.py.exp
tests/extmod/uasyncio_current_task.py.exp
+1
-0
No files found.
docs/library/uasyncio.rst
View file @
7ed99544
...
...
@@ -40,6 +40,10 @@ Core functions
Returns the corresponding `Task` object.
.. function:: current_task()
Return the `Task` object associated with the currently running task.
.. function:: run(coro)
Create a new task from the given coroutine and run it until it completes.
...
...
extmod/uasyncio/core.py
View file @
7ed99544
...
...
@@ -264,6 +264,10 @@ def get_event_loop(runq_len=0, waitq_len=0):
return
Loop
def
current_task
():
return
cur_task
def
new_event_loop
():
global
_task_queue
,
_io_queue
# TaskQueue of Task instances
...
...
tests/extmod/uasyncio_current_task.py
0 → 100644
View file @
7ed99544
# 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
())
tests/extmod/uasyncio_current_task.py.exp
0 → 100644
View file @
7ed99544
True
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment