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