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:
|
||||
return json.loads(read_url(url, data, timeout=60).decode('utf-8'))['data']
|
||||
except:
|
||||
logger.debug('metadata request failed', exc_info=1)
|
||||
return {}
|
||||
|
||||
def find(query):
|
||||
|
|
|
@ -353,8 +353,9 @@ def can_connect_dns(host="8.8.8.8", port=53):
|
|||
port: 53/tcp
|
||||
"""
|
||||
try:
|
||||
socket.setdefaulttimeout(1)
|
||||
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1)
|
||||
s.connect((host, port))
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue