Skip to content

Commit

Permalink
Use gethostname instead of potentially slow getfqdn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ssbarnea committed Mar 18, 2022
1 parent 91bbd7f commit 927312b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2375.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid potential 30s delay caused by socket.getfqdn(). -- by :user:`ssbarnea`
2 changes: 1 addition & 1 deletion src/tox/logs/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 927312b

Please sign in to comment.