https://github.com/python/cpython/commit/5ce47b96b0ea8b7391a4da2856a9553f4cbf35eb
commit: 5ce47b96b0ea8b7391a4da2856a9553f4cbf35eb
branch: 3.13
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-05-12T14:16:52Z
summary:
[3.13] gh-133744: Fix multiprocessing interrupt test: add an event (#133746)
(#133917)
gh-133744: Fix multiprocessing interrupt test: add an event (#133746)
Add an event to synchronize the parent process with the child
process: wait until the child process starts sleeping.
(cherry picked from commit c2989b7070b18c0b7c51521fed8bc11c159ea5b8)
files:
A Misc/NEWS.d/next/Tests/2025-05-09-14-54-48.gh-issue-133744.LCquu0.rst
M Lib/test/_test_multiprocessing.py
diff --git a/Lib/test/_test_multiprocessing.py
b/Lib/test/_test_multiprocessing.py
index 4b06123011cb66..9e3330e40ffaab 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -511,6 +511,11 @@ def _test_process_mainthread_native_id(cls, q):
def _sleep_some(cls):
time.sleep(100)
+ @classmethod
+ def _sleep_some_event(cls, event):
+ event.set()
+ time.sleep(100)
+
@classmethod
def _test_sleep(cls, delay):
time.sleep(delay)
@@ -519,7 +524,8 @@ def _kill_process(self, meth):
if self.TYPE == 'threads':
self.skipTest('test not appropriate for {}'.format(self.TYPE))
- p = self.Process(target=self._sleep_some)
+ event = self.Event()
+ p = self.Process(target=self._sleep_some_event, args=(event,))
p.daemon = True
p.start()
@@ -537,8 +543,11 @@ def _kill_process(self, meth):
self.assertTimingAlmostEqual(join.elapsed, 0.0)
self.assertEqual(p.is_alive(), True)
- # XXX maybe terminating too soon causes the problems on Gentoo...
- time.sleep(1)
+ timeout = support.SHORT_TIMEOUT
+ if not event.wait(timeout):
+ p.terminate()
+ p.join()
+ self.fail(f"event not signaled in {timeout} seconds")
meth(p)
diff --git
a/Misc/NEWS.d/next/Tests/2025-05-09-14-54-48.gh-issue-133744.LCquu0.rst
b/Misc/NEWS.d/next/Tests/2025-05-09-14-54-48.gh-issue-133744.LCquu0.rst
new file mode 100644
index 00000000000000..f19186db1adb79
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2025-05-09-14-54-48.gh-issue-133744.LCquu0.rst
@@ -0,0 +1,3 @@
+Fix multiprocessing interrupt test. Add an event to synchronize the parent
+process with the child process: wait until the child process starts
+sleeping. Patch by Victor Stinner.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]