mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Always try to reconnect within Connection
This commit is contained in:
parent
2c1d3ee2a4
commit
03629d5ee9
@ -27,8 +27,6 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Connection:
|
class Connection:
|
||||||
MAX_RETRIES = 3
|
|
||||||
|
|
||||||
MODES = {
|
MODES = {
|
||||||
0: TCPFull,
|
0: TCPFull,
|
||||||
1: TCPAbridged,
|
1: TCPAbridged,
|
||||||
@ -50,7 +48,7 @@ class Connection:
|
|||||||
self.is_connected = asyncio.Event()
|
self.is_connected = asyncio.Event()
|
||||||
|
|
||||||
async def connect(self):
|
async def connect(self):
|
||||||
for i in range(Connection.MAX_RETRIES):
|
while True:
|
||||||
self.protocol = self.mode(self.ipv6, self.proxy)
|
self.protocol = self.mode(self.ipv6, self.proxy)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -69,9 +67,6 @@ class Connection:
|
|||||||
self.mode.__name__,
|
self.mode.__name__,
|
||||||
))
|
))
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
log.warning("Couldn't connect. Trying again...")
|
|
||||||
raise TimeoutError
|
|
||||||
|
|
||||||
self.is_connected.set()
|
self.is_connected.set()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user