Skip to content

Instantly share code, notes, and snippets.

@vodik
Created November 14, 2017 16:42
Show Gist options
  • Save vodik/6533a34696e8b9884e8769002a6087f3 to your computer and use it in GitHub Desktop.
Save vodik/6533a34696e8b9884e8769002a6087f3 to your computer and use it in GitHub Desktop.
def wrapper(iterable):
print("start")
results = yield from iterable
print("stop")
results[:] = [1, 1, 1]
return results
def multicall(*callables):
all_results = []
for c in callables:
result = c()
all_results.append(result)
yield result
return all_results
results = wrapper(multicall(lambda: 1, lambda: 2, lambda: 3))
try:
print(next(results))
print(next(results))
print(next(results))
print(next(results))
except StopIteration as e:
assert e.value == [1, 1, 1]
print(e.value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment