Skip to content

Commit

Permalink
hadoop_http.py: use exit 1 when interfaces are not listening
Browse files Browse the repository at this point in the history
  • Loading branch information
johann8384 authored and vasiliyk committed Apr 30, 2024
1 parent a96f57c commit 981bd3a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion collectors/lib/hadoop_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
try:
# noinspection PyCompatibility
from http.client import HTTPConnection
from http.client import NotConnected
except ImportError:
# noinspection PyUnresolvedReferences,PyCompatibility
from httplib import HTTPConnection
from httplib import NotConnected


EXCLUDED_KEYS = (
Expand Down Expand Up @@ -65,7 +67,11 @@ def request(self):
try:
self.server.request('GET', self.uri)
resp = self.server.getresponse().read()
except:
except ConnectionRefusedError as exc:
sys.stderr.write("Could not connect to %s" % (self.uri))
sys.exit(1)
except Exception as exc:
sys.stderr.write("Unexpected error: %s" % (exc))
resp = '{}'
finally:
self.server.close()
Expand Down

0 comments on commit 981bd3a

Please sign in to comment.