https://github.com/python/cpython/commit/18e4eb410ad0cb2f0ba6aac92d40db7c9346e2c0 commit: 18e4eb410ad0cb2f0ba6aac92d40db7c9346e2c0 branch: 3.12 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: vstinner <vstin...@python.org> date: 2025-03-17T15:57:28Z summary:
[3.12] gh-130727: Retry test_wmi on TimeoutError (GH-130832) (#130840) gh-130727: Retry test_wmi on TimeoutError (GH-130832) Use sleeping_retry() in test_wmi to retry multiple times on TimeoutError. Wait up to LONG_TIMEOUT seconds (5 minutes by default). (cherry picked from commit f67ff9e82071b21c1960401aed4844b00b5bfb53) Co-authored-by: Victor Stinner <vstin...@python.org> files: M Lib/test/test_wmi.py diff --git a/Lib/test/test_wmi.py b/Lib/test/test_wmi.py index f667926d1f8ddf..111f990656ced5 100644 --- a/Lib/test/test_wmi.py +++ b/Lib/test/test_wmi.py @@ -3,7 +3,8 @@ import time import unittest -from test.support import import_helper, requires_resource, LOOPBACK_TIMEOUT +from test import support +from test.support import import_helper # Do this first so test will be skipped if module doesn't exist @@ -12,15 +13,16 @@ def wmi_exec_query(query): # gh-112278: WMI maybe slow response when first call. - try: - return _wmi.exec_query(query) - except BrokenPipeError: - pass - except WindowsError as e: - if e.winerror != 258: - raise - time.sleep(LOOPBACK_TIMEOUT) - return _wmi.exec_query(query) + for _ in support.sleeping_retry(support.LONG_TIMEOUT): + try: + return _wmi.exec_query(query) + except BrokenPipeError: + pass + # retry on pipe error + except WindowsError as exc: + if exc.winerror != 258: + raise + # retry on timeout class WmiTests(unittest.TestCase): @@ -58,7 +60,7 @@ def test_wmi_query_not_select(self): with self.assertRaises(ValueError): wmi_exec_query("not select, just in case someone tries something") - @requires_resource('cpu') + @support.requires_resource('cpu') def test_wmi_query_overflow(self): # Ensure very big queries fail # Test multiple times to ensure consistency _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com