Last active
August 23, 2016 04:21
-
-
Save Jamesernator/d9e56bf2e8407a6ee6ea8b9f1c527ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def yieldfromexample(): | |
RESULT = yield from EXPR | |
# Would become | |
async def yieldfromexample(): | |
_i = aiter(EXPR) | |
try: | |
_y = await anext(_i) | |
except StopAsyncIteration as _e: | |
_r = _e.value | |
else: | |
while 1: | |
try: | |
_s = yield _y | |
except GeneratorExit as _e: | |
try: | |
_m = _i.aclose | |
except AttributeError: | |
pass | |
else: | |
await _m() | |
raise _e | |
except BaseException as _e: | |
_x = sys.exc_info() | |
try: | |
_m = _i.athrow | |
except AttributeError: | |
raise _e | |
else: | |
try: | |
_y = await _m(*_x) | |
except StopAsyncIteration as _e: | |
_r = _e.value | |
break | |
else: | |
try: | |
if _s is None: | |
_y = await anext(_i) | |
else: | |
_y = await _i.asend(_s) | |
except StopAsyncIteration as _e: | |
_r = _e.value | |
break | |
RESULT = _r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment