def fn(): strand_1 = yield tap.CallFork(receiver, (1, )) strand_2 = yield tap.CallFork(receiver, (2, )) strand_3 = yield tap.CallFork(receiver, (3, )) results = yield tap.Fork([ tap.First([strand_1, strand_2, strand_3]), tap.First([strand_2, strand_1]), ]) yield tap.Call(broadcaster, (5, )) yield tap.Call(broadcaster, (3, )) yield tap.Call(broadcaster, (1, )) value = yield tap.Join(results) return value
def fn(): strand_1 = yield tap.CallFork(receiver, (1, )) strand_2 = yield tap.CallFork(receiver, (2, )) strand_3 = yield tap.CallFork(receiver, (3, )) results = yield tap.Fork([ tap.First([strand_1, strand_2], name="1v2"), tap.First([strand_2, strand_3], name="2v3"), ]) yield tap.Call(broadcaster, (5, )) yield tap.Call(broadcaster, (1, )) yield tap.Call(broadcaster, (3, )) value = yield tap.Join(results, name="joinfork") yield tap.Join(strand_2, name="joincanceled") return value
def fn(): intercept_strand = yield tap.CallFork(intercepter) yield tap.Cancel(intercept_strand) recv_strand = yield tap.CallFork(receiver) # even though this is forked, it doesn't end up hanging yield tap.Call(broadcaster, (5, )) # this gets intercepted and never gets injected yield tap.Join(recv_strand)
def fn(): intercept_strand = yield tap.CallFork(intercepter) yield tap.Cancel(intercept_strand) recv_strand = yield tap.CallFork(receiver) # even though this is forked, it doesn't end up hanging yield tap.Call(broadcaster, (5, )) value = yield tap.Join(recv_strand) assert value == 5 # did *not* get intercepted return value
def fn(): x = yield tap.Call(random, (5, )) return x
def fn(): release = yield lock.Acquire() yield tap.Call(dummy, (release, )) yield release