Pass `pub_service` directly to stream RPC
Keep the `@pub` docstring example's remote target namespace addressable by passing the module-level function directly to `Portal.open_stream_from()`. Forward the topic and task-name inputs as RPC kwargs instead of wrapping the target in a `functools.partial` object that resolves to the wrong namespace path. Review: PR #484 (OpenCode) https://github.com/goodboy/tractor/pull/484#pullrequestreview-5025383596 (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))drop_ria_nursery
parent
09e78ad087
commit
4134726ec4
|
|
@ -217,7 +217,6 @@ def pub(
|
|||
|
||||
.. code:: python
|
||||
|
||||
from functools import partial
|
||||
import tractor
|
||||
|
||||
async with tractor.open_nursery() as n:
|
||||
|
|
@ -226,11 +225,9 @@ def pub(
|
|||
enable_modules=[__name__],
|
||||
)
|
||||
async with portal.open_stream_from(
|
||||
partial( # func to execute in it
|
||||
pub_service,
|
||||
topics=('clicks', 'users'),
|
||||
task_name='source1',
|
||||
)
|
||||
pub_service, # func to execute in it
|
||||
topics=('clicks', 'users'),
|
||||
task_name='source1',
|
||||
) as stream:
|
||||
async for value in stream:
|
||||
print(f"Subscriber received {value}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue