From 07e1669e6dc0db5fa63e86de8bb532a0bd8067a0 Mon Sep 17 00:00:00 2001 From: goodboy Date: Mon, 6 Jul 2026 12:31:27 -0400 Subject: [PATCH] Fix stale `@pub` docstring example in `experimental` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `_pubsub.pub` decorator's usage example predates several API generations: ancient positional-arg-order `run_in_actor()` (a missing `await` too) plus the deprecated `portal.result()` — and `run_in_actor()` never allowed streaming funcs anyway. Show the canonical `start_actor()` + `Portal.open_stream_from()` consumption instead (#477 removal sweep). (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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tractor/experimental/_pubsub.py b/tractor/experimental/_pubsub.py index c9bf13d6..76c2cea0 100644 --- a/tractor/experimental/_pubsub.py +++ b/tractor/experimental/_pubsub.py @@ -221,16 +221,19 @@ def pub( import tractor async with tractor.open_nursery() as n: - portal = n.run_in_actor( + portal = await n.start_actor( 'publisher', # actor name - partial( # func to execute in it + enable_modules=[__name__], + ) + async with portal.open_stream_from( + partial( # func to execute in it pub_service, topics=('clicks', 'users'), task_name='source1', ) - ) - async for value in await portal.result(): - print(f"Subscriber received {value}") + ) as stream: + async for value in stream: + print(f"Subscriber received {value}") Here, you don't need to provide the ``ctx`` argument since the