def test_spawn_many(): # This dependencies dict sets up a graph like this: # a # / \ # b c # \ /| # d | # \| # e deps = dict(e="cd", d="bc", c="a", b="a", a="") capture = Capture() pool = DAGPool() # spawn a waitall() waiter externally to our DAGPool, but capture its # message in same Capture instance eventlet.spawn(waitall_done, capture, pool) pool.spawn_many(deps, spawn_many_func, capture, pool) # This set of greenthreads should in fact run to completion once spawned. spin() # verify that e completed (also that post(key) within greenthread # overrides implicit post of return value, which would be None) assert_equals(pool.get("e"), "e") # With the dependency graph shown above, it is not guaranteed whether b or # c will complete first. Handle either case. sequence = capture.sequence[:] sequence[1:3] = [set([sequence[1].pop(), sequence[2].pop()])] assert_equals(sequence, [ set(["a done"]), set(["b done", "c done"]), set(["d done"]), set(["e done"]), set(["waitall() done"]), ])
def test_spawn_many(): # This dependencies dict sets up a graph like this: # a # / \ # b c # \ /| # d | # \| # e deps = dict(e="cd", d="bc", c="a", b="a", a="") capture = Capture() pool = DAGPool() # spawn a waitall() waiter externally to our DAGPool, but capture its # message in same Capture instance eventlet.spawn(waitall_done, capture, pool) pool.spawn_many(deps, spawn_many_func, capture, pool) # This set of greenthreads should in fact run to completion once spawned. spin() # verify that e completed (also that post(key) within greenthread # overrides implicit post of return value, which would be None) assert_equals(pool.get("e"), "e") # With the dependency graph shown above, it is not guaranteed whether b or # c will complete first. Handle either case. sequence = capture.sequence[:] sequence[1:3] = [set([sequence[1].pop(), sequence[2].pop()])] assert_equals(sequence, [set(["a done"]), set(["b done", "c done"]), set(["d done"]), set(["e done"]), set(["waitall() done"]), ])