Skip to content

Instantly share code, notes, and snippets.

@ask
Last active March 22, 2019 23:54
Show Gist options
  • Save ask/fb1f0aba00a28f62ed6d56453790fc9b to your computer and use it in GitHub Desktop.
Save ask/fb1f0aba00a28f62ed6d56453790fc9b to your computer and use it in GitHub Desktop.

Revisions

  1. ask revised this gist Mar 22, 2019. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions finally_in_asynciterator_does_not_work_in_Python3.7
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,6 @@ class Bar:
    for i in range(10):
    try:
    yield i
    except Exception as exc:
    print('GOT ERROR: %r' % (exc,))
    finally:
    print('FOO')

  2. ask created this gist Mar 22, 2019.
    26 changes: 26 additions & 0 deletions finally_in_asynciterator_does_not_work_in_Python3.7
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    # finally: behavior changed from Python 3.6 to Python 3.7

    async def foo():
    try:
    async for item in Bar():
    raise Exception('foo')
    except Exception:
    pass



    class Bar:

    async def __aiter__(self):
    for i in range(10):
    try:
    yield i
    except Exception as exc:
    print('GOT ERROR: %r' % (exc,))
    finally:
    print('FOO')


    if __name__ == '__main__':
    import asyncio
    loop = asyncio.get_event_loop()