-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Task
methods to make _asyncio
more similar to cpython
#8647
base: main
Are you sure you want to change the base?
feat: add Task
methods to make _asyncio
more similar to cpython
#8647
Conversation
Adds methods that are in CPython, such as `exception`, `result`, `get_coro`, `cancelled`, `add_done_callback`, and `remove_done_callback`. Also adds support for the unary hash so tasks may be collected in a python set.
This is a follow up from #8576 & is the same code as in micropython#13000 This is different from #8576 in that it doesn't define the exceptions as part of the C code and instead pulls them in from the asyncio context that's passed to the |
Ouch. Build failed for one of the smallest devices that there's not enough flash. This increases things by a few hundred bytes so that might indeed be the case? If that's the only failure I'll be opening this PR |
This board should have |
drops ulab from the thunderpack v12 to drastically reduce the byte usage of flash
Added the commit from #8650 to this PR instead per request - to reduce the number of full builds required. |
I"m going to make this a draft while micropython#13000 is in process. |
This updates the way that Task is handled in the C module for asyncio which implements tasks & task queues. The goal is to bring
asyncio
in CircuitPython slightly closer to CPython.This adds the following methods to
Task
:get_coro()
- how CPython exposes the coroutine backing the task (CPython Docs)result()
- a helper method from CPython for returning the successful response (CPython Docs)exception()
- a helper method from CPython for returning the raised values (CPython Docs)cancelled()
- helper for true / false if the task has been cancelled (CPython Docs)add_done_callback()
- adds a callback to the task for completion or if already complete executes it (CPython docs)remove_done_callback()
- removes a specific "done" callback from the task (CPython docs)Moves
CancelledError
& createsInvalidStateError
in the extmodAdds a
hash
unary operation soTask
s can be added to sets.