mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 15:34:52 +00:00
Don't try to indefinitely reconnect at Connection layer
This commit is contained in:
parent
00b983ccc3
commit
81d3d5956c
1 changed files with 5 additions and 1 deletions
|
|
@ -26,6 +26,8 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Connection:
|
class Connection:
|
||||||
|
MAX_RETRIES = 5
|
||||||
|
|
||||||
MODES = {
|
MODES = {
|
||||||
0: TCPFull,
|
0: TCPFull,
|
||||||
1: TCPAbridged,
|
1: TCPAbridged,
|
||||||
|
|
@ -40,7 +42,7 @@ class Connection:
|
||||||
self.connection = None
|
self.connection = None
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
while True:
|
for i in range(Connection.MAX_RETRIES):
|
||||||
self.connection = self.mode(self.proxy)
|
self.connection = self.mode(self.proxy)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -51,6 +53,8 @@ class Connection:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
raise TimeoutError
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.connection.close()
|
self.connection.close()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue