logreader: skip internal source if connection refused (#32418)

* logreader: skip internal source if connection refused

* fix indentation

* fix spacing

* explicit ipv4 and tcp
old-commit-hash: 2a46d71fc8
pull/32199/head
Greg Hogan 12 months ago committed by GitHub
parent d71879a4af
commit a17639bddb
  1. 9
      tools/lib/filereader.py

@ -10,10 +10,11 @@ DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/")
def internal_source_available():
try:
hostname = urlparse(DATA_ENDPOINT).hostname
if hostname:
socket.gethostbyname(hostname)
return True
except socket.gaierror:
port = urlparse(DATA_ENDPOINT).port or 80
with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s:
s.connect((hostname, port))
return True
except (socket.gaierror, ConnectionRefusedError):
pass
return False

Loading…
Cancel
Save