From e35fcaa5294f44d5501d535e55b327f918e0a375 Mon Sep 17 00:00:00 2001 From: Paul Nilsson Date: Mon, 2 Dec 2024 10:50:01 +0100 Subject: [PATCH] Improved exception handling for socket related errors --- pilot/util/tracereport.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pilot/util/tracereport.py b/pilot/util/tracereport.py index d6b25ca5..b3607be4 100644 --- a/pilot/util/tracereport.py +++ b/pilot/util/tracereport.py @@ -114,7 +114,7 @@ def init(self, job): try: hostname = os.environ.get('PANDA_HOSTNAME', socket.gethostname()) - except socket.herror as exc: + except (socket.gaierror, socket.herror) as exc: logger.warning(f'unable to detect hostname for trace report: {exc}') hostname = os.environ.get('PANDA_HOSTNAME', 'unknown') @@ -126,7 +126,7 @@ def init(self, job): try: self['ip'] = socket.gethostbyname(hostname) - except socket.herror as exc: + except (socket.gaierror, socket.herror) as exc: logger.debug(f"unable to detect host IP for trace report: {exc}") self['ip'] = '0.0.0.0'