Skip to content

fix(asyncio): abort protocol calls on task cancellation#3144

Merged
Skn0tt merged 1 commit into
microsoft:mainfrom
Skn0tt:skn0tt-address-3134-followup
Jul 17, 2026
Merged

fix(asyncio): abort protocol calls on task cancellation#3144
Skn0tt merged 1 commit into
microsoft:mainfrom
Skn0tt:skn0tt-address-3134-followup

Conversation

@Skn0tt

@Skn0tt Skn0tt commented Jul 17, 2026

Copy link
Copy Markdown
Member

This implements the follow-up left in #3134 and finishes the cancellation behaviour introduced in #1236.

#1236 made cancelled asyncio tasks cancel their local protocol callback. The stated intention was to propagate cancellation to the protocol call, but the driver operation kept running because the protocol couldn't abort it yet.

With __abort__, cancelling a task now stops the driver operation and waits for its protocol response before re-raising CancelledError. This follows asyncio's guidance to propagate cancellation after cleanup completes.

This is an observable behaviour change: previously, a cancelled action could still happen later. Users who intentionally want an operation to outlive its caller can run it in a separate task and protect it with asyncio.shield().

The regression test blocks a click, cancels it, unblocks the button, and verifies that it stays unclicked.

Complete cancellation propagation now that the driver supports protocol aborts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c3c85ae6-2b5f-4f50-9158-ce3c886f750a
@Skn0tt
Skn0tt requested a review from dgozman July 17, 2026 11:47
@Skn0tt
Skn0tt merged commit 86d3004 into microsoft:main Jul 17, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants