Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-130727: Retry test_wmi on TimeoutError #130832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions Lib/test/test_wmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Loading