mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-20 13:32:04 +08:00
logreader: skip internal source if connection refused (#32418)
* logreader: skip internal source if connection refused * fix indentation * fix spacing * explicit ipv4 and tcp
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user