Fix stale `@pub` docstring example in `experimental`

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
drop_ria_nursery
Gud Boi 2026-07-06 12:31:27 -04:00
parent d6bed7c4a0
commit 07e1669e6d
1 changed files with 8 additions and 5 deletions

View File

@ -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