Skip to content

Commit

Permalink
src/sage/doctest/util.py: handle NoSuchProcess from psutil, too
Browse files Browse the repository at this point in the history
Like ZombieProcess... this can happen. And the doctest framework
shouldn't crash if a pexpect process was killed.
  • Loading branch information
orlitzky committed Oct 16, 2024
1 parent d9dbe60 commit 98dbd96
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
from psutil import NoSuchProcess, Process, ZombieProcess
try:
cputime += sum(Process(S.pid()).cpu_times()[0:2])
except (ImportError, ValueError, ZombieProcess):
except (ImportError, ValueError, NoSuchProcess, ZombieProcess):
# ImportError: no psutil
# ValueError: invalid (e.g. negative) PID
# NoSuchProcess: it's gone
# ZombieProcess: PID refers to a zombie
pass

Expand Down

0 comments on commit 98dbd96

Please sign in to comment.