Skip to content

Instantly share code, notes, and snippets.

@fabiocerqueira
Last active December 14, 2016 19:04
Show Gist options
  • Save fabiocerqueira/8a89da798b3d4d3319533f826772095f to your computer and use it in GitHub Desktop.
Save fabiocerqueira/8a89da798b3d4d3319533f826772095f to your computer and use it in GitHub Desktop.
from types import coroutine
@coroutine
def spam():
result = yield 'somevalue'
print("Got it:", result)
async def foo():
print('Start foo')
await spam()
print('End foo')
if __name__ == '__main__':
ret = None
f = spam()
while 1:
try:
ret = f.send(ret)
except StopIteration:
break
print('#' * 20)
print('Testing foo...')
print('#' * 20)
ret = None
f = foo()
while 1:
try:
ret = f.send(ret)
except StopIteration:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment