]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] [tests] test_subprocess maybe avoid a timeout race condition? (GH-133420)...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 5 May 2025 04:25:41 +0000 (06:25 +0200)
committerGitHub <noreply@github.com>
Mon, 5 May 2025 04:25:41 +0000 (04:25 +0000)
[tests] test_subprocess maybe avoid a timeout race condition? (GH-133420)

The few buildbot failures on https://github.com/python/cpython/pull/133103
are possibly just due to racing a child process launch and exit?
(cherry picked from commit b64aa302d7bc09454ba8d5b19922ff6a4192dd96)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Lib/test/test_subprocess.py

index ba02b1a1c011a1ea05d43b8eba2ff9297e628593..8b2f48b0fc0119c82fa8bb89adf01b977b2625eb 100644 (file)
@@ -163,13 +163,13 @@ class ProcessTestCase(BaseTestCase):
 
     def test_timeout_exception(self):
         try:
-            subprocess.run(['echo', 'hi'], timeout = -1)
+            subprocess.run([sys.executable, '-c', 'import time;time.sleep(9)'], timeout = -1)
         except subprocess.TimeoutExpired as e:
             self.assertIn("-1 seconds", str(e))
         else:
             self.fail("Expected TimeoutExpired exception not raised")
         try:
-            subprocess.run(['echo', 'hi'], timeout = 0)
+            subprocess.run([sys.executable, '-c', 'import time;time.sleep(9)'], timeout = 0)
         except subprocess.TimeoutExpired as e:
             self.assertIn("0 seconds", str(e))
         else: