Skip to content

Commit 927312b

Browse files
committed
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
1 parent 91bbd7f commit 927312b

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

docs/changelog/2375.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid potential 30s delay caused by socket.getfqdn(). -- by :user:`ssbarnea`

src/tox/logs/result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self):
2222
"reportversion": "1",
2323
"toxversion": __version__,
2424
"platform": sys.platform,
25-
"host": os.getenv(str("HOSTNAME")) or socket.getfqdn(),
25+
"host": os.getenv(str("HOSTNAME")) or socket.gethostname(),
2626
"commands": command_log,
2727
}
2828

tests/unit/test_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_pre_set_header(clean_hostname_envvar):
3131
assert replog.dict["reportversion"] == "1"
3232
assert replog.dict["toxversion"] == tox.__version__
3333
assert replog.dict["platform"] == sys.platform
34-
assert replog.dict["host"] == socket.getfqdn()
34+
assert replog.dict["host"] == socket.gethostname()
3535
data = replog.dumps_json()
3636
replog2 = ResultLog.from_json(data)
3737
assert replog2.dict == replog.dict
@@ -44,7 +44,7 @@ def test_set_header(pkg, clean_hostname_envvar):
4444
assert replog.dict["reportversion"] == "1"
4545
assert replog.dict["toxversion"] == tox.__version__
4646
assert replog.dict["platform"] == sys.platform
47-
assert replog.dict["host"] == socket.getfqdn()
47+
assert replog.dict["host"] == socket.gethostname()
4848
expected = {"basename": "hello-1.0.tar.gz", "sha256": pkg.computehash("sha256")}
4949
env_log = replog.get_envlog("a")
5050
env_log.set_header(installpkg=pkg)

0 commit comments

Comments
 (0)