Skip to content

Commit

Permalink
fix: race condition in test_posix.TestProcess.test_cmdline (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Oct 8, 2022
1 parent 7271ec7 commit 0707c16
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
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

0 comments on commit 0707c16

Please sign in to comment.