diff --git a/oml/metaremote.py b/oml/metaremote.py index d2a23e0..b6f6c77 100644 --- a/oml/metaremote.py +++ b/oml/metaremote.py @@ -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): diff --git a/oml/utils.py b/oml/utils.py index 9b99a7b..454c4e0 100644 --- a/oml/utils.py +++ b/oml/utils.py @@ -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