]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-140729: Fix subprocess handling in test_process_pool_executor_pickle (#141688)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Tue, 18 Nov 2025 02:26:40 +0000 (02:26 +0000)
committerGitHub <noreply@github.com>
Tue, 18 Nov 2025 02:26:40 +0000 (02:26 +0000)
Lib/test/test_profiling/test_sampling_profiler.py

index 2d00173c22c419fccdda3bea56202a5309d1695b..c2cc2ddd48a02cef328cdc196096c6159c309e8c 100644 (file)
@@ -3311,6 +3311,8 @@ if __name__ == "__main__":
         self.assertNotIn("<native>", output)
 
 
+@requires_subprocess()
+@skip_if_not_supported
 class TestProcessPoolExecutorSupport(unittest.TestCase):
     """
     Test that ProcessPoolExecutor works correctly with profiling.sampling.
@@ -3339,12 +3341,15 @@ if __name__ == "__main__":
                     "-d", "5",
                     "-i", "100000",
                     script,
+                    stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     text=True
                 ) as proc:
-                    proc.wait(timeout=SHORT_TIMEOUT)
-                    stdout = proc.stdout.read()
-                    stderr = proc.stderr.read()
+                    try:
+                        stdout, stderr = proc.communicate(timeout=SHORT_TIMEOUT)
+                    except subprocess.TimeoutExpired:
+                        proc.kill()
+                        stdout, stderr = proc.communicate()
 
         if "PermissionError" in stderr:
             self.skipTest("Insufficient permissions for remote profiling")