Repository navigation
gh-159534: Fix race condition in test_sampling_profiler - #160028
Conversation
Fix test_is_python_process_non_python_subprocess(). Wait until the forked process calls exec() before calling is_python_process(). Previously, is_python_build() returned True if exec() was not called yet in the forked process.
| if os.path.exists(f"/proc/{proc.pid}/exe"): | ||
| return True | ||
| else: | ||
| return True |
There was a problem hiding this comment.
On non-Linux platforms, this function basically did nothing. So in my change, I only call the function on Linux.
|
|
||
| try: | ||
| if sys.platform == "linux": | ||
| if os.path.exists(f"/proc/{proc.pid}/exe"): |
There was a problem hiding this comment.
I'm not sure of the purpose of the old test. Just after fork, /proc/pid/exe is a symlink to the Python executable (and it does exist). After fork+exec, /proc/pid/exe is a symlink to /usr/bin/sleep (which also exists). I don't see when /proc/pid/exe doesn't exist.
|
cc @pablogsal |
|
With this change, |
| _wait_for_process_ready(proc, SHORT_TIMEOUT), | ||
| f"Process {proc.pid} should be ready within {SHORT_TIMEOUT}s", | ||
| ) | ||
| if sys.platform == "linux": |
There was a problem hiding this comment.
There's
@unittest.skipUnless(sys.platform == "linux", "Linux only test")already.
|
It seems like Android failed during a download, it's a flaky failure: |
|
The test failed again on AMD64 Debian root 3.x: https://buildbot.python.org/#/builders/345/builds/15753. So let me merge this fix. |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-160080 is a backport of this pull request to the 3.15 branch. |
…0028) (#160080) gh-159534: Fix race condition in test_sampling_profiler (GH-160028) Fix test_is_python_process_non_python_subprocess(). Wait until the forked Python process calls exec() before calling is_python_process(). Previously, is_python_build() returned True if exec() was not called yet in the forked process. (cherry picked from commit 6fd15f0) Co-authored-by: Victor Stinner <vstinner@python.org>
Fix test_is_python_process_non_python_subprocess(). Wait until the forked process calls exec() before calling is_python_process(). Previously, is_python_build() returned True if exec() was not called yet in the forked process.