Skip to content

Commit 5a4a82f

Browse files
1 parent 4d1a242 commit 5a4a82f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

adslproxy/sender/sender.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from loguru import logger
1010
from retrying import retry, RetryError
1111
import redis
12+
from redis.exceptions import ConnectionError
1213

1314
if platform.python_version().startswith('2.'):
1415
import commands as subprocess
@@ -116,14 +117,17 @@ def run(self):
116117
else:
117118
proxy = '{ip}:{port}'.format(ip=ip, port=PROXY_PORT)
118119
time.sleep(10)
119-
if self.test_proxy(proxy):
120-
logger.info(f'Valid proxy {proxy}')
121-
# 将代理放入数据库
122-
self.set_proxy(proxy)
123-
time.sleep(DIAL_CYCLE)
124-
else:
125-
logger.error(f'Proxy invalid {proxy}')
126-
else:
120+
try:
121+
if self.test_proxy(proxy):
122+
logger.info(f'Valid proxy {proxy}')
123+
# 将代理放入数据库
124+
self.set_proxy(proxy)
125+
time.sleep(DIAL_CYCLE)
126+
else:
127+
logger.error(f'Proxy invalid {proxy}')
128+
except ConnectionError:
129+
logger.error('The redis connection is abnormal')
130+
else :
127131
# 获取 IP 失败,重新拨号
128132
logger.error('Get IP failed, re-dialing')
129133
self.run()

0 commit comments

Comments
 (0)