summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--changelogs/fragments/fix-module-utils-facts-timeout.yml2
-rw-r--r--lib/ansible/module_utils/facts/timeout.py2
-rw-r--r--test/units/modules/test_mount_facts.py4
3 files changed, 4 insertions, 4 deletions
diff --git a/changelogs/fragments/fix-module-utils-facts-timeout.yml b/changelogs/fragments/fix-module-utils-facts-timeout.yml
new file mode 100644
index 0000000000..3ecc95dfab
--- /dev/null
+++ b/changelogs/fragments/fix-module-utils-facts-timeout.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - Use the requested error message in the ansible.module_utils.facts.timeout timeout function instead of hardcoding one.
diff --git a/lib/ansible/module_utils/facts/timeout.py b/lib/ansible/module_utils/facts/timeout.py
index 5fb749fb6b..3b0476245b 100644
--- a/lib/ansible/module_utils/facts/timeout.py
+++ b/lib/ansible/module_utils/facts/timeout.py
@@ -48,7 +48,7 @@ def timeout(seconds=None, error_message="Timer expired"):
return res.get(timeout_value)
except multiprocessing.TimeoutError:
# This is an ansible.module_utils.common.facts.timeout.TimeoutError
- raise TimeoutError('Timer expired after %s seconds' % timeout_value)
+ raise TimeoutError(f'{error_message} after {timeout_value} seconds')
finally:
pool.terminate()
diff --git a/test/units/modules/test_mount_facts.py b/test/units/modules/test_mount_facts.py
index 64f36a6934..2a2faec52c 100644
--- a/test/units/modules/test_mount_facts.py
+++ b/test/units/modules/test_mount_facts.py
@@ -272,9 +272,7 @@ def test_get_mount_size_timeout(monkeypatch, set_file_content, on_timeout, shoul
raise Exception("Timeout failed")
monkeypatch.setattr(mount_facts, "get_mount_size", mock_slow_function)
- # FIXME
- # match = "Timed out getting mount size .*"
- match = "Timer expired after 0.1 seconds"
+ match = r"Timed out getting mount size for mount /proc \(type proc\) after 0.1 seconds"
if should_raise:
with pytest.raises(AnsibleFailJson, match=match):