async def test_task_stream_clear_interval(c, s, a, b): ts = TaskStream(s, clear_interval=200) await wait(c.map(inc, range(10))) ts.update() await asyncio.sleep(0.01) await wait(c.map(dec, range(10))) ts.update() assert len(set(map(len, ts.source.data.values()))) == 1 assert ts.source.data["name"].count("inc") == 10 assert ts.source.data["name"].count("dec") == 10 await asyncio.sleep(0.3) await wait(c.map(inc, range(10, 20))) ts.update() assert len(set(map(len, ts.source.data.values()))) == 1 assert ts.source.data["name"].count("inc") == 10 assert ts.source.data["name"].count("dec") == 0
def test_task_stream(c, s, a, b): ts = TaskStream(s) futures = c.map(slowinc, range(10), delay=0.001) yield wait(futures) ts.update() d = dict(ts.source.data) assert all(len(L) == 10 for L in d.values()) assert min(d["start"]) == 0 # zero based ts.update() d = dict(ts.source.data) assert all(len(L) == 10 for L in d.values()) total = c.submit(sum, futures) yield wait(total) ts.update() d = dict(ts.source.data) assert len(set(map(len, d.values()))) == 1