forked from goodboy/tractor
Add timeout around test and prints for guidance
parent
52627a6326
commit
f617da6ff1
|
@ -21,6 +21,8 @@ async def streamer(
|
|||
await stream.send(val)
|
||||
await trio.sleep(0.001)
|
||||
|
||||
print('producer finished')
|
||||
|
||||
|
||||
@acm
|
||||
async def open_stream() -> Awaitable[tractor.MsgStream]:
|
||||
|
@ -32,18 +34,16 @@ async def open_stream() -> Awaitable[tractor.MsgStream]:
|
|||
ctx.open_stream() as stream,
|
||||
):
|
||||
yield stream
|
||||
breakpoint()
|
||||
|
||||
print('CANCELLING STREAMER')
|
||||
await portal.cancel_actor()
|
||||
print('CANCELLED STREAMER')
|
||||
|
||||
|
||||
@acm
|
||||
async def maybe_open_stream(taskname: str):
|
||||
async with tractor.trionics.maybe_open_context(
|
||||
# NOTE: all secondary tasks should cache hit on the same key
|
||||
key='stream',
|
||||
mngr=open_stream(),
|
||||
acm_func=open_stream,
|
||||
) as (cache_hit, stream):
|
||||
|
||||
if cache_hit:
|
||||
|
@ -86,13 +86,13 @@ def test_open_local_sub_to_stream():
|
|||
seq = []
|
||||
async for msg in stream:
|
||||
seq.append(msg)
|
||||
print(f'{taskname} received {msg}')
|
||||
|
||||
assert set(seq).issubset(set(full))
|
||||
print(f'{taskname} finished')
|
||||
|
||||
# TODO: turns out this isn't multi-task entrant XD
|
||||
# We probably need an indepotent entry semantic?
|
||||
with trio.fail_after(3):
|
||||
async with tractor.open_root_actor():
|
||||
async with (
|
||||
trio.open_nursery() as nurse,
|
||||
|
@ -101,4 +101,6 @@ def test_open_local_sub_to_stream():
|
|||
nurse.start_soon(get_sub_and_pull, f'task_{i}')
|
||||
await trio.sleep(0.001)
|
||||
|
||||
print('all consumer tasks finished')
|
||||
|
||||
trio.run(main)
|
||||
|
|
Loading…
Reference in New Issue