mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +03:00
Fix disconnection without a previous connection
This commit is contained in:
parent
b31b239088
commit
c1be0bd2e8
|
@ -251,12 +251,17 @@ class MTProtoSender:
|
||||||
self._log.info('Connection to %s complete!', self._connection)
|
self._log.info('Connection to %s complete!', self._connection)
|
||||||
|
|
||||||
async def _disconnect(self, error=None):
|
async def _disconnect(self, error=None):
|
||||||
|
if self._connection is None:
|
||||||
|
self._log.info('Not disconnecting (already have no connection)')
|
||||||
|
return
|
||||||
|
|
||||||
self._log.info('Disconnecting from %s...', self._connection)
|
self._log.info('Disconnecting from %s...', self._connection)
|
||||||
self._user_connected = False
|
self._user_connected = False
|
||||||
try:
|
try:
|
||||||
self._log.debug('Closing current connection...')
|
self._log.debug('Closing current connection...')
|
||||||
await self._connection.disconnect()
|
await self._connection.disconnect()
|
||||||
finally:
|
finally:
|
||||||
|
self._connection = None
|
||||||
self._log.debug('Cancelling {} pending message(s)...'
|
self._log.debug('Cancelling {} pending message(s)...'
|
||||||
.format(len(self._pending_state)))
|
.format(len(self._pending_state)))
|
||||||
for state in self._pending_state.values():
|
for state in self._pending_state.values():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user