From a06885dd14956029c76e4554b122829dbc068b48 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 19:56:25 +0100 Subject: [PATCH] Add support for "async with" context manager --- pyrogram/client/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index bf0401da..0327615a 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -243,6 +243,12 @@ class Client(Methods, BaseClient): def __exit__(self, *args): self.stop() + async def __aenter__(self): + return await self.start() + + async def __aexit__(self, *args): + await self.stop() + @property def proxy(self): return self._proxy