async def test_TaskGroupGraph_arrows(c, s, a, b): tgg = TaskGroupGraph(s) futures = c.map(inc, range(10)) await wait(futures) tgg.update() assert all(len(L) == 1 for L in tgg.nodes_source.data.values()) assert tgg.nodes_source.data["name"] == ["inc"] assert tgg.nodes_source.data["tot_tasks"] == [10] assert all(len(L) == 0 for L in tgg.arrows_source.data.values()) futures2 = c.map(dec, futures) await wait(futures2) tgg.update() assert all(len(L) == 2 for L in tgg.nodes_source.data.values()) assert tgg.nodes_source.data["name"] == ["inc", "dec"] assert tgg.nodes_source.data["tot_tasks"] == [10, 10] assert all(len(L) == 1 for L in tgg.arrows_source.data.values()) del futures, futures2 while s.task_groups: await asyncio.sleep(0.01) tgg.update() # for some reason after deleting the futures the tgg.node_source.data.values are not clear. assert not any(tgg.nodes_source.data.values()) assert not any(tgg.arrows_source.data.values())
async def test_TaskGroupGraph(c, s, a, b): tgg = TaskGroupGraph(s) futures = c.map(inc, range(10)) await wait(futures) tgg.update() assert all(len(L) == 1 for L in tgg.nodes_source.data.values()) assert tgg.nodes_source.data["name"] == ["inc"] assert tgg.nodes_source.data["tot_tasks"] == [10] assert all(len(L) == 0 for L in tgg.arrows_source.data.values()) futures2 = c.map(dec, range(5)) await wait(futures2) tgg.update() assert all(len(L) == 2 for L in tgg.nodes_source.data.values()) assert tgg.nodes_source.data["name"] == ["inc", "dec"] assert tgg.nodes_source.data["tot_tasks"] == [10, 5] del futures, futures2 while s.task_groups: await asyncio.sleep(0.01) tgg.update() assert not any(tgg.nodes_source.data.values())