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
|
.. code:: python
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
import tractor
|
import tractor
|
||||||
|
|
||||||
async with tractor.open_nursery() as n:
|
async with tractor.open_nursery() as n:
|
||||||
|
|
@ -226,11 +225,9 @@ def pub(
|
||||||
enable_modules=[__name__],
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
async with portal.open_stream_from(
|
async with portal.open_stream_from(
|
||||||
partial( # func to execute in it
|
pub_service, # func to execute in it
|
||||||
pub_service,
|
|
||||||
topics=('clicks', 'users'),
|
topics=('clicks', 'users'),
|
||||||
task_name='source1',
|
task_name='source1',
|
||||||
)
|
|
||||||
) as stream:
|
) as stream:
|
||||||
async for value in stream:
|
async for value in stream:
|
||||||
print(f"Subscriber received {value}")
|
print(f"Subscriber received {value}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue