Skip to content

[3.13] gh-133744: Fix multiprocessing interrupt test: add an event (#133746) #133917

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
May 12, 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
15 changes: 12 additions & 3 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
@@ -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)

Original file line number Diff line number Diff line change
@@ -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.
Loading
Oops, something went wrong.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant