Skip to content

Instantly share code, notes, and snippets.

@EnotYoyo
Created March 25, 2019 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EnotYoyo/d751951c5ff77e22686715aa9ab05b56 to your computer and use it in GitHub Desktop.
Save EnotYoyo/d751951c5ff77e22686715aa9ab05b56 to your computer and use it in GitHub Desktop.
import asyncio
class Manager:
async def __aenter__(self):
print("aenter")
return object()
async def __aexit__(self, *exc_info):
print("aexit")
async def get_obj():
async with Manager() as obj:
yield obj
async def main():
async for obj in get_obj():
raise Exception
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
# print aenter and Exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment