From 361d99185c10c8ce21a8c2dac5e5ef0454625fef Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Fri, 18 Mar 2022 13:18:21 +0000 Subject: [PATCH] Use gethostname instead of potentially slow getfqdn This avoid bug that is adding 30s on some machines where getfqdn() is very slow, as this is caused by an unsolved python bug. Related: https://bugs.python.org/issue35164 Fixes: #2375 --- src/tox/logs/result.py | 2 +- tests/unit/test_result.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tox/logs/result.py b/src/tox/logs/result.py index 73d61039f2..d81e22b8a4 100644 --- a/src/tox/logs/result.py +++ b/src/tox/logs/result.py @@ -22,7 +22,7 @@ def __init__(self): "reportversion": "1", "toxversion": __version__, "platform": sys.platform, - "host": os.getenv(str("HOSTNAME")) or socket.getfqdn(), + "host": os.getenv(str("HOSTNAME")) or socket.gethostname(), "commands": command_log, } diff --git a/tests/unit/test_result.py b/tests/unit/test_result.py index efbd3f9cbf..3b7ee89b4a 100644 --- a/tests/unit/test_result.py +++ b/tests/unit/test_result.py @@ -31,7 +31,7 @@ def test_pre_set_header(clean_hostname_envvar): assert replog.dict["reportversion"] == "1" assert replog.dict["toxversion"] == tox.__version__ assert replog.dict["platform"] == sys.platform - assert replog.dict["host"] == socket.getfqdn() + assert replog.dict["host"] == socket.gethostname() data = replog.dumps_json() replog2 = ResultLog.from_json(data) assert replog2.dict == replog.dict @@ -44,7 +44,7 @@ def test_set_header(pkg, clean_hostname_envvar): assert replog.dict["reportversion"] == "1" assert replog.dict["toxversion"] == tox.__version__ assert replog.dict["platform"] == sys.platform - assert replog.dict["host"] == socket.getfqdn() + assert replog.dict["host"] == socket.gethostname() expected = {"basename": "hello-1.0.tar.gz", "sha256": pkg.computehash("sha256")} env_log = replog.get_envlog("a") env_log.set_header(installpkg=pkg)