@async_context_manager async def ctx(): await open() try: yield finally: await close() async with ctx(): await ...