From bc91a1bdfa8b35c68294c482a52fc82975299dd1 Mon Sep 17 00:00:00 2001 From: goodboy Date: Thu, 25 Jun 2026 20:32:05 -0400 Subject: [PATCH] Inline `send_yield` body to drop its deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `experimental._pubsub`'s `fan_out_to_ctxs()` pushed each packet via the now-deprecated `Context.send_yield()`, tripping its own `DeprecationWarning` on every published msg. Inline that method's exact body — `await ctx.chan.send(Yield(cid=ctx.cid, pld=payload))` — so the wire msg stays byte-identical (still a `Yield`) yet no warning fires. The "proper" fix (swap to `MsgStream.send()` via `Context.open_stream()`) needs BOTH sides migrated: the subscriber still uses the legacy `Portal.open_stream_from()` which never calls `.started()`, so a publisher-side `open_stream()` raises a `RuntimeError` ("`started()` must be called before opening a stream") — verified. Left as the module's standing rework TODO. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/experimental/_pubsub.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tractor/experimental/_pubsub.py b/tractor/experimental/_pubsub.py index 50a9906c..08760200 100644 --- a/tractor/experimental/_pubsub.py +++ b/tractor/experimental/_pubsub.py @@ -38,6 +38,7 @@ import wrapt from ..log import get_logger from .._context import Context +from ..msg import Yield __all__ = ['pub'] @@ -88,7 +89,18 @@ async def fan_out_to_ctxs( if ctx_payloads: for ctx, payload in ctx_payloads: try: - await ctx.send_yield(payload) + # NOTE: inline the (now-deprecated) + # `Context.send_yield()` body to drop its + # `DeprecationWarning` without a behaviour change. + # The "proper" fix is migrating BOTH sides to + # `open_context()`/`open_stream()`, but the + # subscriber still uses the legacy + # `Portal.open_stream_from()` (no `started()` + # handshake) so `Context.open_stream()` can't be + # used here yet — see this module's rework TODO. + await ctx.chan.send( + Yield(cid=ctx.cid, pld=payload) + ) except ( # That's right, anything you can think of... trio.ClosedResourceError, ConnectionResetError,