dont set global socket timeout

This commit is contained in:
j 2015-12-24 17:58:11 +05:30
parent 98714e35e7
commit 96a3cdb4b2
2 changed files with 4 additions and 2 deletions

View file

@ -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):

View file

@ -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