Repository navigation
fix: preserve cancellation during async flag evaluation - #693
Draft
frajberrima wants to merge 1 commit into
Draft
frajberrima wants to merge 1 commit into
frajberrima wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
Prepared with AI assistance; reviewed and DCO attestation confirmed by the submitting author. Signed-off-by: frajberrima <frajberrima98@gmail.com>
frajberrima
force-pushed
the
fix/async-evaluation-cancellation
branch
from
December 2, 2026 21:11
d6bc3f6 to
a625c31
Compare
This branch has not been deployed
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.
Cancelling an in-progress async flag evaluation raises
UnboundLocalErrorfrom final-hook dispatch because the provider await exits beforeflag_evaluationis assigned. Sinceasyncio.CancelledErrorderives fromBaseException, the ordinary exception handlers do not initialize those details. The same failure preventsasyncio.wait_forfrom reporting its expected timeout.Handle cancellation explicitly, construct default-valued error details for final hooks, and re-raise the original cancellation. The application still receives cancellation; the default is only cleanup metadata. Ordinary provider-error handling is unchanged.
Eight regression cases cover all supported value shapes, the exact provider-raised cancellation object without hooks, and actual task timeout behavior. They fail before the patch and pass afterward. Events synchronize provider startup without sleep-based races.
Validation on Windows: all 234 pytest tests and all 21 Gherkin scenarios pass on Python 3.10.22, 3.11.18, 3.12.16, 3.13.18, 3.14.10 and 3.15.2. Ruff, formatting, repository text/configuration hooks, wheel and sdist builds pass. Strict mypy passes with
--num-workers 0because parallel workers encounter a Windows IPC limitation. Gherkin uses the pinned specification fixtures; live flagd integration and hosted Linux CI have not been run.The proposed cancellation policy calls final hooks with
Reason.ERRORandErrorCode.GENERAL, but does not call ordinaryerrorhooks for cancellation. The specification does not separately define Python cancellation semantics, so this policy needs maintainer review.This contribution was prepared with AI assistance. The submitting author has reviewed the contribution and confirmed the DCO attestation; the commit includes their Signed-off-by line. Hosted build, lint, and test workflows currently await repository approval.