Repository navigation
Release v0.17.0 - #457
Merged
Merged
Release v0.17.0#457
Conversation
The pool created its proxy at context entry and dropped the reference, keeping only the context manager. Nothing could route a call through a pool named by its receiver without a handle on the proxy serving it. Bind the proxy the factory yields to the pool for the lifetime of the context, and clear it in a finally so a failed exit leaves no handle behind. Behavior is unchanged; the ambient dispatch path still resolves its proxy from the caller's context.
A routine call dispatches through whichever pool is ambient in the caller's context. Naming a pool instead required either entering it or accepting the keyword collision that kept executor out of wool.to_thread: a pool keyword would silently shadow any routine parameter of the same name. Express the choice through the receiver. WorkerPool.dispatch takes the routine positionally and reserves no keyword, so every keyword reaches the routine. One routine goes to one worker, selected by the pool's load balancer, and the task carries that pool's proxy, so the nested calls the routine makes route through it as well. The routine layer gains the seam this needs. Each decorated wrapper carries a dispatch entrypoint matching its call shape, and dispatch_through routes one call through a proxy its caller names rather than the ambient one. The attribute's absence is what rejects an undecorated callable, which is a rejection the explicit path needs because it is handed a callable rather than invoking one: an undecorated coroutine function is callable and awaitable, so it would run in the caller's own process while the call reported a dispatch. A bound method or classmethod carries its receiver out of band, where an ambient call carries it in the argument list. Unbinding on the way through restores the ambient shape, so obj.method takes the same arguments dispatched as it does called.
Add the explicit-dispatch section to the package README, and correct the worker README's note on concurrent pool entry, which described every dispatch path as binding a context variable. WorkerPool.dispatch binds nothing, threading the retained proxy to the routine layer explicitly, so it never raises ChainContention.
The docstring had three structural defects alongside its prose ones. Its summary line was nominal rather than imperative; the bulk of its prose sat after the field list, where the documented section order puts only examples and the implementation rubric; and it still carried the legacy role markup that new prose is not to introduce. Reorder to summary, prose, field list, examples, rubric. Replace the two interleaved note directives and the six-item best-practices list with named subsections that separate what the process boundary guarantees from what it constrains, collapsing the three items that were advice or restated parity into the claims carrying them. Convert the role markup to the single-backtick convention. No contract claim is dropped.
Drive the dispatch cases through the proxy boundary and assert on the public task fields, so the suite exercises the real dispatch entrypoint rather than a patched stand-in, and the bound-callable contract becomes observable at this level. The stream relay was the gap worth closing. A dispatched async generator relays its result stream without calling asend until the consumer sends a value, and nothing reached that guard through the pool: replacing it with an unconditional asend passed the entire suite. A stream implementing no asend now fails that mutation.
Exercise the override against live workers: a call routed to the receiver while another pool is ambient, the ambient pool restored afterwards and after a stream is abandoned mid-iteration, concurrent dispatches isolated under gather, nested calls following the task's proxy, the generator protocol forwarded end to end, an exception propagated from the routine, and the routine running under the caller's chain.
The explicit path routes through WorkerProxy.dispatch, so every composition axis the matrix varies is live for it, and none was covering it: transport credentials, discovery, pool mode, channel limits, backpressure and the context-var patterns. Add explicit coroutine and async generator shapes to the routine dimension, following the convention the nested shapes already set of naming a dispatch path rather than a callable shape. Extract the generator step driver so the ambient and explicit arms share it instead of duplicating the per-yield assertions. The pairwise filter and the Hypothesis strategy already admit every binding for a shape that pins none, so the two stay in agreement untouched.
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 cut release workflow.