mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Create a separate method to start reconnections
This commit is contained in:
parent
0d0e78e10b
commit
184424957d
|
@ -305,6 +305,11 @@ class MTProtoSender:
|
|||
__log__.error('Failed to reconnect automatically.')
|
||||
await self._disconnect(error=ConnectionError())
|
||||
|
||||
def _start_reconnect(self):
|
||||
"""Starts a reconnection in the background."""
|
||||
if self._user_connected:
|
||||
self._loop.create_task(self._reconnect())
|
||||
|
||||
def _clean_containers(self, msg_ids):
|
||||
"""
|
||||
Helper method to clean containers from the pending messages
|
||||
|
@ -378,7 +383,7 @@ class MTProtoSender:
|
|||
__log__.exception('Unhandled exception while receiving')
|
||||
await asyncio.sleep(1)
|
||||
|
||||
self._loop.create_task(self._reconnect())
|
||||
self._start_reconnect()
|
||||
break
|
||||
else:
|
||||
# Remove the cancelled messages from pending
|
||||
|
@ -417,7 +422,7 @@ class MTProtoSender:
|
|||
__log__.exception('Unhandled exception while receiving')
|
||||
await asyncio.sleep(1)
|
||||
|
||||
self._loop.create_task(self._reconnect())
|
||||
self._start_reconnect()
|
||||
break
|
||||
|
||||
# TODO Check salt, session_id and sequence_number
|
||||
|
@ -436,7 +441,7 @@ class MTProtoSender:
|
|||
# an actually broken authkey?
|
||||
__log__.warning('Broken authorization key?: {}'.format(e))
|
||||
self.state.auth_key = None
|
||||
self._loop.create_task(self._reconnect())
|
||||
self._start_reconnect()
|
||||
break
|
||||
except SecurityError as e:
|
||||
# A step while decoding had the incorrect data. This message
|
||||
|
|
Loading…
Reference in New Issue
Block a user