def parent(env): condition_A = all_of([env.timeout(i, value=i) for i in range(2)]) condition_B = all_of([env.timeout(i, value=i) for i in range(2)]) condition_A &= condition_B results = yield condition_A assert sorted(results.values()) == [0, 0, 1, 1]
def parent(env): event = env.timeout(1) yield env.timeout(2) try: all_of([event]) assert False, 'Expected an exception' except RuntimeError as e: assert e.args[0] == 'Event Timeout(1) has already been triggered'
def parent(env): condition_A = all_of([env.timeout(i, value=i) for i in range(2)]) condition_B = all_of([env.timeout(i, value=i) for i in range(2)]) yield env.timeout(0) condition = condition_A & condition_B assert sorted(condition._get_results().values()) == [0, 0] results = yield condition assert sorted(results.values()) == [0, 0, 1, 1]
def parent(env): # Start 10 events. events = [env.timeout(i, value=i) for i in range(10)] results = yield all_of(events) assert results == {events[i]: i for i in range(10)} assert env.now == 9
def parent(env): events = [env.timeout(1, value=1), env.start(child_with_error(env, 2)), env.timeout(3, value=3)] try: condition = all_of(events) yield condition assert False, 'There should have been an exception' except RuntimeError as e: assert e.args[0] == 'crashing' # Although the condition has failed, intermediate results are # available. assert condition._results[events[0]] == 1 assert condition._results[events[1]].args[0] == 'crashing' # The last child has not terminated yet. assert events[2] not in condition._results
def parent(env): events = [ env.timeout(1, value=1), env.start(child_with_error(env, 2)), env.timeout(3, value=3) ] try: condition = all_of(events) yield condition assert False, 'There should have been an exception' except RuntimeError as e: assert e.args[0] == 'crashing' # Although the condition has failed, intermediate results are # available. assert condition._results[events[0]] == 1 assert condition._results[events[1]].args[0] == 'crashing' # The last child has not terminated yet. assert events[2] not in condition._results