From 51f082fff77e4c98f2be7e67b2eb962d9c5160f0 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 15 Feb 2019 17:10:57 -0500 Subject: [PATCH] Use mem chan in streaming tests --- tests/test_streaming.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_streaming.py b/tests/test_streaming.py index e25a000..55b4bee 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -91,25 +91,25 @@ async def aggregate(seed): portals.append(portal) - q = trio.Queue(500) + send_chan, recv_chan = trio.open_memory_channel(500) - async def push_to_q(portal): + async def push_to_chan(portal): async for value in await portal.run( __name__, 'stream_data', seed=seed ): # leverage trio's built-in backpressure - await q.put(value) + await send_chan.send(value) - await q.put(None) + await send_chan.send(None) print(f"FINISHED ITERATING {portal.channel.uid}") # spawn 2 trio tasks to collect streams and push to a local queue async with trio.open_nursery() as n: for portal in portals: - n.start_soon(push_to_q, portal) + n.start_soon(push_to_chan, portal) unique_vals = set() - async for value in q: + async for value in recv_chan: if value not in unique_vals: unique_vals.add(value) # yield upwards to the spawning parent actor