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