Repository navigation
fix: handle cancellation in async event predicates - #3380
Closed
himanshug189-sketch wants to merge 1 commit into
Closed
himanshug189-sketch wants to merge 1 commit into
himanshug189-sketch wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This was referenced Nov 26, 2026
Author
|
Hi, I've updated the PR description with a clearer explanation of the root cause, reproduction steps, expected behaviour, implementation details, and test verification. I've also strengthened the regression test to verify that the response event listener is cleaned up after an async predicate raises I've pushed the latest changes to the same branch. Could you please consider reopening this PR so I can continue addressing any review feedback? I understand there may be overlapping work on the same issue. I'm happy to coordinate and avoid duplicate changes. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes async event predicate cancellation handling so that
asyncio.CancelledErroris propagated correctly and the associated event listener is cleaned up.Problem
When an asynchronous predicate passed to an event-waiting API such as
page.expect_response()raisesasyncio.CancelledError, the existing implementation does not handle it correctly.The async predicate continuation catches
Exception, butasyncio.CancelledErrorinherits fromBaseException. As a result, it bypasses the normal failure handler, potentially leaving the event waiter's promise unresolved and causing the expectation to hang until timeout.Reproduction
The regression test reproduces the issue using the following steps:
server.EMPTY_PAGE.asyncio.CancelledError.page.expect_response(predicate).fetch('/digits/1.png').Expected Behaviour
asyncio.CancelledErrorshould propagate to the caller.Implementation
BaseException.asyncio.CancelledErrorin the asynchronous predicate continuation.Verification
Executed:
python -m pytest tests/async/python/test_page.py -k "async_predicate" --browser chromium -qResult: 2 passed, 7 deselected on Python 3.12.3.