Make disconnect synchronous

This also fixes a bug when auto-reconnecting in MTProtoSender.
This commit is contained in:
Lonami Exo
2018-10-16 11:56:17 +02:00
parent 477fbd8dc7
commit 9cbc088b76
6 changed files with 28 additions and 34 deletions

View File

@@ -119,7 +119,7 @@ class MTProtoSender:
def is_connected(self):
return self._user_connected
async def disconnect(self):
def disconnect(self):
"""
Cleanly disconnects the instance from the network, cancels
all pending requests, and closes the send and receive loops.
@@ -223,7 +223,7 @@ class MTProtoSender:
else:
e = ConnectionError('auth_key generation failed {} times'
.format(self._retries))
await self._disconnect(error=e)
self._disconnect(error=e)
raise e
__log__.debug('Starting send loop')
@@ -310,7 +310,7 @@ class MTProtoSender:
break
else:
__log__.error('Failed to reconnect automatically.')
await self._disconnect(error=ConnectionError())
self._disconnect(error=ConnectionError())
def _start_reconnect(self):
"""Starts a reconnection in the background."""