Skip to content

Sync main with master#279

Merged
wool-labs[bot] merged 3 commits into
mainfrom
master
Jul 2, 2026
Merged

Sync main with master#279
wool-labs[bot] merged 3 commits into
mainfrom
master

Conversation

@wool-labs

@wool-labs wool-labs Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Auto-generated by the sync branches workflow.

conradbzura and others added 3 commits July 2, 2026 19:00
The task factory records every armed task in the module-global
_task_contexts map so a context re-driven by a second task raises
wool.ChainContention. The map held its tasks strongly and evicted them
from a per-task _release done-callback. When the per-dispatch worker
loop is torn down before that callback runs the eviction is stranded,
and the entry, with the task it pins, leaks. Under sustained dispatch
the process task set grows without bound, and the per-teardown
asyncio.all_tasks scan it feeds grows with it.

Make _task_contexts a weakref.WeakValueDictionary so an entry drops as
soon as its task is collected, whether or not _release runs. The
_PENDING reservation sentinel is a strongly-referenced module
singleton, so reserved slots never evaporate, and the id-reuse safety
invariant holds because a live weak entry implies its task, and thus
its context, is still alive. _release stays an eager best-effort
eviction and the factory-displacement backstop.
Exercise the weak _task_contexts map through public observables. A
registered task whose _release callback is stranded by loop teardown is
evicted once it is unreferenced and collected, so the leak is bounded;
the assertion fails against the old strong map. The _PENDING
reservation survives a gc.collect within its window, verified through a
re-entrant wool.ChainContention raise. The contention guard still fires
for a live armed context after a forced collection, folded into the
existing shared-context test by parametrization.
@wool-labs wool-labs Bot merged commit f5a2665 into main Jul 2, 2026
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.

1 participant