mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 13:14:31 +03:00
Make reconnect private
This commit is contained in:
parent
bc15b451b5
commit
4245ec5abc
|
@ -181,7 +181,7 @@ class TelegramBareClient:
|
||||||
"""Disconnects from the Telegram server"""
|
"""Disconnects from the Telegram server"""
|
||||||
self._sender.disconnect()
|
self._sender.disconnect()
|
||||||
|
|
||||||
def reconnect(self, new_dc=None):
|
def _reconnect(self, new_dc=None):
|
||||||
"""If 'new_dc' is not set, only a call to .connect() will be made
|
"""If 'new_dc' is not set, only a call to .connect() will be made
|
||||||
since it's assumed that the connection has been lost and the
|
since it's assumed that the connection has been lost and the
|
||||||
library is reconnecting.
|
library is reconnecting.
|
||||||
|
@ -325,7 +325,7 @@ class TelegramBareClient:
|
||||||
except ConnectionResetError:
|
except ConnectionResetError:
|
||||||
self._logger.debug('Server disconnected us. Reconnecting and '
|
self._logger.debug('Server disconnected us. Reconnecting and '
|
||||||
'resending request...')
|
'resending request...')
|
||||||
self.reconnect()
|
self._reconnect()
|
||||||
|
|
||||||
except FloodWaitError:
|
except FloodWaitError:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
|
|
@ -268,14 +268,14 @@ class TelegramClient(TelegramBareClient):
|
||||||
# For normal use cases, this won't happen, because this will only
|
# For normal use cases, this won't happen, because this will only
|
||||||
# be on the very first connection (not authorized, not running),
|
# be on the very first connection (not authorized, not running),
|
||||||
# but may be an issue for people who actually travel?
|
# but may be an issue for people who actually travel?
|
||||||
self.reconnect(new_dc=e.new_dc)
|
self._reconnect(new_dc=e.new_dc)
|
||||||
return self.invoke(request)
|
return self.invoke(request)
|
||||||
|
|
||||||
except ConnectionResetError:
|
except ConnectionResetError:
|
||||||
if self._connect_lock.locked():
|
if self._connect_lock.locked():
|
||||||
# We are connecting and we don't want to reconnect there...
|
# We are connecting and we don't want to reconnect there...
|
||||||
raise
|
raise
|
||||||
while self._user_connected and not self.reconnect():
|
while self._user_connected and not self._reconnect():
|
||||||
pass # Retry forever until we finally can send the request
|
pass # Retry forever until we finally can send the request
|
||||||
|
|
||||||
# Let people use client(SomeRequest()) instead client.invoke(...)
|
# Let people use client(SomeRequest()) instead client.invoke(...)
|
||||||
|
@ -1065,7 +1065,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
pass
|
pass
|
||||||
except ConnectionResetError:
|
except ConnectionResetError:
|
||||||
self._logger.debug('Server disconnected us. Reconnecting...')
|
self._logger.debug('Server disconnected us. Reconnecting...')
|
||||||
while self._user_connected and not self.reconnect():
|
while self._user_connected and not self._reconnect():
|
||||||
pass # Retry forever, this is instant messaging
|
pass # Retry forever, this is instant messaging
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user