Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug issue#15: https://github.com/Python3WebSpider/AdslProxy/issues/… #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions adslproxy/sender/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from loguru import logger
from retrying import retry, RetryError
import redis
from redis.exceptions import ConnectionError

if platform.python_version().startswith('2.'):
import commands as subprocess
Expand Down Expand Up @@ -116,14 +117,17 @@ def run(self):
else:
proxy = '{ip}:{port}'.format(ip=ip, port=PROXY_PORT)
time.sleep(10)
if self.test_proxy(proxy):
logger.info(f'Valid proxy {proxy}')
# 将代理放入数据库
self.set_proxy(proxy)
time.sleep(DIAL_CYCLE)
else:
logger.error(f'Proxy invalid {proxy}')
else:
try:
if self.test_proxy(proxy):
logger.info(f'Valid proxy {proxy}')
# 将代理放入数据库
self.set_proxy(proxy)
time.sleep(DIAL_CYCLE)
else:
logger.error(f'Proxy invalid {proxy}')
except ConnectionError:
logger.error('The redis connection is abnormal')
else :
# 获取 IP 失败,重新拨号
logger.error('Get IP failed, re-dialing')
self.run()
Expand Down