Skip to content
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

extmod/uasyncio: Fix cancellation handling of wait_for. #6667

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented Dec 1, 2020

This is a fix for #5797 to make uasyncio.wait_for() handle cancellation correctly.

This is an alternative to #5918 and #5931. The advantage of the approach here is that it still only uses one extra task (one extra call to create_task()) to implement the wait-for. It basically switches the roles of this helper task from a cancellation task to a runner task.

Note that the asyncio.get_event_loop().set_exception_handler(lambda loop, context: None) line needed in the test can be removed if/when #6664 is merged.

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Dec 1, 2020
@dpgeorge dpgeorge force-pushed the extmod-uasyncio-fix-wait-for branch 2 times, most recently from 5825778 to e274243 Compare December 1, 2020 04:58
@kevinkk525
Copy link
Contributor

Works in my tests too and does look better than my attempts.

@dpgeorge
Copy link
Member Author

dpgeorge commented Dec 1, 2020

Works in my tests too and does look better than my attempts.

Thanks for testing. I matched some of the additional tests here to yours, which helped iron out bugs.

This commit switches the roles of the helper task from a cancellation task
to a runner task, to get the correct semantics for cancellation of
wait_for.

Some uasyncio tests are now disabled for the native emitter due to issues
with native code generation of generators and yield-from.

Fixes micropython#5797.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge merged commit b505971 into micropython:master Dec 2, 2020
@dpgeorge dpgeorge deleted the extmod-uasyncio-fix-wait-for branch December 2, 2020 01:52
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants