gh-109582: test_fork_signal_handling should wait for event#109605
gh-109582: test_fork_signal_handling should wait for event#109605vstinner merged 1 commit intopython:mainfrom
Conversation
|
Does this need a changelog entry? The failing test was introduced in 3.12. |
No, because it's just a test fix. |
| @@ -1911,8 +1913,14 @@ def test_fork_signal_handling(self): | |||
| parent_handled = manager.Event() | |||
|
|
|||
There was a problem hiding this comment.
I didn't know that another test_asyncio test uses multiprocessing.
It might be interesting to call from multiprocessing.util._cleanup_tests() in this test file as well: see commit 09ea4b8 and gh-109295.
But this one is less important since it doesn't pull most heavy multiprocessing resources, it's "just" a fork manager :-)
| signal.signal(signal.SIGTERM, on_sigterm) | ||
| child_started.set() | ||
| while True: | ||
| time.sleep(1) |
There was a problem hiding this comment.
It took me a while to understand that the child doesn't run the loop forever, but is interrupted by SIGTERM and so exits immediately.
|
|
||
| asyncio.run(main()) | ||
|
|
||
| child_handled.wait(timeout=support.SHORT_TIMEOUT) |
There was a problem hiding this comment.
Right, that's a good way to synchronize the parent and the child.
|
Merged thanks. I copied your rationale in the commit message. IMO it's important to keep it. |
…honGH-109605) Sometimes the child_handled event was missing because either the child quits before it gets a chance to handle the signal, or the parent asserts before the event notification is delivered via IPC. Synchronize explicitly to avoid this. (cherry picked from commit 608c1f3) Co-authored-by: Davide Rizzo <sorcio@gmail.com>
|
GH-109695 is a backport of this pull request to the 3.12 branch. |
|
|
…hon#109605) Sometimes the child_handled event was missing because either the child quits before it gets a chance to handle the signal, or the parent asserts before the event notification is delivered via IPC. Synchronize explicitly to avoid this.
…-109605) (#109695) gh-109582: test_fork_signal_handling should wait for event (GH-109605) Sometimes the child_handled event was missing because either the child quits before it gets a chance to handle the signal, or the parent asserts before the event notification is delivered via IPC. Synchronize explicitly to avoid this. (cherry picked from commit 608c1f3) Co-authored-by: Davide Rizzo <sorcio@gmail.com>
…hon#109605) Sometimes the child_handled event was missing because either the child quits before it gets a chance to handle the signal, or the parent asserts before the event notification is delivered via IPC. Synchronize explicitly to avoid this.
Sometimes the child_handled event was missing because either the child quits before it gets a chance to handle the signal, or the parent asserts before the event notification is delivered via IPC. Synchronize explicitly to avoid this.