avoid unnecessary failures in get_hostname

The catch clause was specific to one error type, but other errors may also happen such as socket.herror. In any case, the point is to fallback anyways.

Bug: b/310216577
Change-Id: I55561f8f40446f90bee27ea2aab1a4e60c03e7e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5024019
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Anas Sulaiman <mrahs@google.com>
Reviewed-by: Michael Savigny <msavigny@google.com>
changes/19/5024019/5
Anas Sulaiman 1 year ago committed by LUCI CQ
parent 481ceeb0b5
commit 7a9b709a6c

@ -125,7 +125,10 @@ def get_hostname():
hostname = socket.gethostname() hostname = socket.gethostname()
try: try:
return socket.gethostbyaddr(hostname)[0] return socket.gethostbyaddr(hostname)[0]
except socket.gaierror: except Exception as e:
print("socket.gethostbyaddr failed " +
"(falling back to socket.gethostname): %s" % e,
file=sys.stderr)
return hostname return hostname

Loading…
Cancel
Save