dont set global socket timeout
This commit is contained in:
parent
98714e35e7
commit
96a3cdb4b2
2 changed files with 4 additions and 2 deletions
|
@ -19,6 +19,7 @@ def request(action, data):
|
||||||
try:
|
try:
|
||||||
return json.loads(read_url(url, data, timeout=60).decode('utf-8'))['data']
|
return json.loads(read_url(url, data, timeout=60).decode('utf-8'))['data']
|
||||||
except:
|
except:
|
||||||
|
logger.debug('metadata request failed', exc_info=1)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def find(query):
|
def find(query):
|
||||||
|
|
|
@ -353,8 +353,9 @@ def can_connect_dns(host="8.8.8.8", port=53):
|
||||||
port: 53/tcp
|
port: 53/tcp
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
socket.setdefaulttimeout(1)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
|
s.settimeout(1)
|
||||||
|
s.connect((host, port))
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue