Skip to content

Commit

Permalink
src/sage/doctest/util.py: ignore ZombieProcess errors from psutil
Browse files Browse the repository at this point in the history
Apparently psutil will raise a custom ZombieProcess exception if you
try to compute the cputime of a zombie process. No problem, we can
ignore those too.
  • Loading branch information
orlitzky committed Oct 15, 2024
1 parent 63db6ab commit 0c58518
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sage/doctest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,13 @@ def _quick_cputime(self, expect_objects):
# installed as a transitive dependency (ipython
# needs it), but it isn't explicitly listed as
# a dependency of sagelib.
from psutil import Process, ZombieProcess
try:
from psutil import Process
cputime += sum(Process(S.pid()).cpu_times()[0:2])
except (ImportError, ValueError):
except (ImportError, ValueError, ZombieProcess):
# ImportError: no psutil
# ValueError: invalid (e.g. negative) PID
# ZombieProcess: PID refers to a zombie
pass

return cputime
Expand Down

0 comments on commit 0c58518

Please sign in to comment.