mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-07 20:42:32 +00:00
Revert disconnect() to be async again (#1133)
It's the only way to properly clean all background tasks, which the library makes heavy use for in MTProto/Connection send and receive loops. Some parts of the code even relied on the fact that it was asynchronous (it used to return a future so you could await it and not be breaking). It's automatically syncified to reduce the damage of being a breaking change.
This commit is contained in:
@@ -440,7 +440,7 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
||||
self._state = types.updates.State(
|
||||
0, 0, datetime.datetime.now(tz=datetime.timezone.utc), 0, 0)
|
||||
|
||||
self.disconnect()
|
||||
await self.disconnect()
|
||||
self.session.delete()
|
||||
return True
|
||||
|
||||
@@ -550,9 +550,9 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
||||
return await self.start()
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.disconnect()
|
||||
self.disconnect() # It's also syncified, like start()
|
||||
|
||||
async def __aexit__(self, *args):
|
||||
self.disconnect()
|
||||
await self.disconnect()
|
||||
|
||||
# endregion
|
||||
|
Reference in New Issue
Block a user