Add support for "async with" context manager

This commit is contained in:
Dan 2019-03-16 19:56:25 +01:00
parent a329e56259
commit a06885dd14

View File

@ -243,6 +243,12 @@ class Client(Methods, BaseClient):
def __exit__(self, *args): def __exit__(self, *args):
self.stop() self.stop()
async def __aenter__(self):
return await self.start()
async def __aexit__(self, *args):
await self.stop()
@property @property
def proxy(self): def proxy(self):
return self._proxy return self._proxy