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

Skip to content

Commit b64aa30

Browse files
authored
[tests] test_subprocess maybe avoid a timeout race condition? (#133420)
The few buildbot failures on #133103 are possibly just due to racing a child process launch and exit?
1 parent 78adb63 commit b64aa30

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/test/test_subprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ def test_call_timeout(self):
164164

165165
def test_timeout_exception(self):
166166
try:
167-
subprocess.run(['echo', 'hi'], timeout = -1)
167+
subprocess.run([sys.executable, '-c', 'import time;time.sleep(9)'], timeout = -1)
168168
except subprocess.TimeoutExpired as e:
169169
self.assertIn("-1 seconds", str(e))
170170
else:
171171
self.fail("Expected TimeoutExpired exception not raised")
172172
try:
173-
subprocess.run(['echo', 'hi'], timeout = 0)
173+
subprocess.run([sys.executable, '-c', 'import time;time.sleep(9)'], timeout = 0)
174174
except subprocess.TimeoutExpired as e:
175175
self.assertIn("0 seconds", str(e))
176176
else:

0 commit comments

Comments
 (0)