Reap the `@pub` example daemon on stream exit
Wrap the documented publisher stream in `try/finally` and explicitly cancel its `start_actor()` daemon. Closing `open_stream_from()` owns only the remote stream task, so actor-nursery exit otherwise waits on the still-running actor indefinitely. 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
4134726ec4
commit
266073cb69
|
|
@ -224,13 +224,16 @@ def pub(
|
||||||
'publisher', # actor name
|
'publisher', # actor name
|
||||||
enable_modules=[__name__],
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
async with portal.open_stream_from(
|
try:
|
||||||
pub_service, # func to execute in it
|
async with portal.open_stream_from(
|
||||||
topics=('clicks', 'users'),
|
pub_service, # func to execute in it
|
||||||
task_name='source1',
|
topics=('clicks', 'users'),
|
||||||
) as stream:
|
task_name='source1',
|
||||||
async for value in stream:
|
) as stream:
|
||||||
print(f"Subscriber received {value}")
|
async for value in stream:
|
||||||
|
print(f"Subscriber received {value}")
|
||||||
|
finally:
|
||||||
|
await portal.cancel_actor()
|
||||||
|
|
||||||
|
|
||||||
Here, you don't need to provide the ``ctx`` argument since the
|
Here, you don't need to provide the ``ctx`` argument since the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue