Sync main with master#281
Merged
Merged
Conversation
The worker driver task runs a coroutine that closes over its DispatchSession, and the session holds the task in _worker_task, so the session, its task, and the task's forked contexts form a reference cycle that only the cyclic collector can reclaim. Under sustained dispatch these accumulate between collections. Clear _worker_task in the task's done-callback once the completion future is settled, breaking the cycle so reference counting reclaims the session and task as soon as the dispatch ends. The only reader after completion, cancel, already tolerates a None task, and teardown synchronizes on the separate completion future, so dropping the reference is safe.
Drive a coroutine dispatch to natural completion and assert the worker driver task is reclaimed, observed through a weakref that clears with automatic collection disabled, so reference counting rather than a cyclic pass frees it. Retain the finished session explicitly to prove it no longer pins the task. The driver task is identified through its coroutine name, as no public handle distinguishes it from an in-flight step task on the worker loop.
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.
Auto-generated by the sync branches workflow.