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-codedrop_ria_nursery
parent
d6bed7c4a0
commit
07e1669e6d
|
|
@ -221,15 +221,18 @@ def pub(
|
||||||
import tractor
|
import tractor
|
||||||
|
|
||||||
async with tractor.open_nursery() as n:
|
async with tractor.open_nursery() as n:
|
||||||
portal = n.run_in_actor(
|
portal = await n.start_actor(
|
||||||
'publisher', # actor name
|
'publisher', # actor name
|
||||||
|
enable_modules=[__name__],
|
||||||
|
)
|
||||||
|
async with portal.open_stream_from(
|
||||||
partial( # func to execute in it
|
partial( # func to execute in it
|
||||||
pub_service,
|
pub_service,
|
||||||
topics=('clicks', 'users'),
|
topics=('clicks', 'users'),
|
||||||
task_name='source1',
|
task_name='source1',
|
||||||
)
|
)
|
||||||
)
|
) as stream:
|
||||||
async for value in await portal.result():
|
async for value in stream:
|
||||||
print(f"Subscriber received {value}")
|
print(f"Subscriber received {value}")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue