Created
March 25, 2019 14:50
-
-
Save EnotYoyo/d751951c5ff77e22686715aa9ab05b56 to your computer and use it in GitHub Desktop.
This file contains 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
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