accept interrupt, shorter timeout
This commit is contained in:
parent
eb8dd6db76
commit
cea5062d10
21
panxy.py
21
panxy.py
@ -29,7 +29,7 @@ def test_proxy(prx):
|
||||
proxy_handler = request.ProxyHandler({'https': 'http://' + prx + '/', 'http': 'http://' + prx + '/' })
|
||||
opener = request.build_opener(proxy_handler)
|
||||
try:
|
||||
result = opener.open(target, timeout=10)
|
||||
result = opener.open(target, timeout=6)
|
||||
content = result.read().decode()
|
||||
print(srv_string + 'ok. \u2705')
|
||||
return True
|
||||
@ -51,13 +51,18 @@ def get_proxies():
|
||||
proxy_list = get_list_from_api()
|
||||
working_list = []
|
||||
start_length = len(proxy_list)
|
||||
for entry in proxy_list:
|
||||
if test_proxy(entry):
|
||||
working_list.append(entry)
|
||||
else:
|
||||
pass
|
||||
print('{}/{} new proxies ready.'.format(len(working_list), start_length))
|
||||
return working_list
|
||||
try:
|
||||
for entry in proxy_list:
|
||||
if test_proxy(entry):
|
||||
working_list.append(entry)
|
||||
else:
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
print(' Impatient? Interrupt again to terminate')
|
||||
|
||||
finally:
|
||||
print('{}/{} new proxies ready.'.format(len(working_list), start_length))
|
||||
return working_list
|
||||
|
||||
def user_loop():
|
||||
proxies = []
|
||||
|
Loading…
Reference in New Issue
Block a user