Repository navigation
Add Python AsyncEventScope for same-thread notifications - #229
Merged
Merged
Conversation
Compose TaskGroup with existing event subscriptions, preserve typed handlers and native lifetimes, and cover installed wheels and real PropertySet notifications. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mixed-language test coverageWorkflow status: ✅ Passed
|
Keep exact callback cardinality and native lifetime checks while accepting Windows path aliases. Exercise a dot-dot temp-root alias in every native run so canonicalization is covered even without NTFS short names. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Python 3.11 preserves dot segments in tempfile paths, unlike 3.12+, and StorageFolder can reject them. Exercise equivalent directory spelling through case instead; retain exact callback count and samefile validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep incoming cancellation out of the cleanup exception group while retaining removal errors. Compare combined internal/external cancellation cases with the running Python version's TaskGroup, including native PropertySet delivery and retryable unsubscription. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Kai Tao (vanzue)
approved these changes
Oct 30, 2026
shisan (qiutongMS)
approved these changes
Oct 30, 2026
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
Add public
dynwinrt.AsyncEventScope, a small typed Python adapter over existingsubscribe_*methods andasyncio.TaskGroup. No Rust ABI, codegen subscription behavior, JavaScript/Node APIs, or generated-package layout changes.on_changedmay be an async function or a callable returning an awaitable. Normal exit removes subscriptions and drains accepted tasks. Handler/body errors and external cancellation use TaskGroup cleanup and propagation. Every unsubscribe is attempted on exit; native removal errors remain observable and saved unsubscribe closures can retry on the owner loop/thread before native lifetimes end.Reproduction and example
Passing a bare
async defto the existingproperties.subscribe_map_changed(handler)creates an unawaited coroutine; it does not schedule the handler. Registering it throughevents.subscribe(...)owns and awaits its work without changing existing synchronous callbacks, raw delegates, or callbacks returning already TaskGroup-owned tasks.With the new runtime installed, follow
samples/python/async-events/README.mdto generate stock Windows bindings, then runapp.pyandapp.py --fail. The sample uses real PropertySet notifications and native async temporary-file I/O; it demonstrates unsubscribe-before-drain and handler-error propagation afterfinallycleanup.Supported boundary
Only ordinary, deferrable-to-later notifications on the same OS thread and actively driven asyncio loop. The application owns the loop, apartment, and projection lifetimes. There is no COM marshaling, WinUI pump integration, synchronous return/Handled/Cancel/deferral support, ordering guarantee, or backpressure policy. Eager task factories can begin handlers inside the native callback; native reentrancy restrictions still apply.
Validation
Based directly on main; independent of #228.