Skip to content
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

fix: race condition in test_posix.TestProcess.test_cmdline #2153

Merged
merged 1 commit into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ I: 1956

N: Matthieu Darbois
W: https://github.com/mayeut
I: 2039, 2142, 2147
I: 2039, 2142, 2147, 2153

N: Hugo van Kemenade
W: https://github.com/hugovk
Expand Down
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ XXXX-XX-XX
- 2147_, [macOS] Fix disk usage report on macOS 12+. (patch by Matthieu Darbois)
- 2150_, [Linux] `Process.threads()`_ may raise ``NoSuchProcess``. Fix race
condition. (patch by Daniel Li)
- 2153_, [macOS] Fix race condition in test_posix.TestProcess.test_cmdline.
(patch by Matthieu Darbois)

5.9.2
=====
Expand Down
6 changes: 6 additions & 0 deletions psutil/tests/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ def test_exe(self):
adjusted_ps_pathname = ps_pathname[:len(ps_pathname)]
self.assertEqual(ps_pathname, adjusted_ps_pathname)

# On macOS the official python installer exposes a python wrapper that
# executes a python executable hidden inside an application bundle inside
# the Python framework.
# There's a race condition between the ps call & the psutil call below
# depending on the completion of the execve call so let's retry on failure
@retry_on_failure()
def test_cmdline(self):
ps_cmdline = ps_args(self.pid)
psutil_cmdline = " ".join(psutil.Process(self.pid).cmdline())
Expand Down