Browse Source

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>
Anas Sulaiman 1 năm trước cách đây
mục cha
commit
7a9b709a6c
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      reclient_helper.py

+ 4 - 1
reclient_helper.py

@@ -125,7 +125,10 @@ def get_hostname():
     hostname = socket.gethostname()
     try:
         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