mirror of
https://github.com/XuehaiPan/nvitop.git
synced 2026-05-21 06:45:24 -06:00
fix(gui/treeview): handle gone processes
This commit is contained in:
parent
dcd2896865
commit
a019b2a718
1 changed files with 7 additions and 1 deletions
|
|
@ -58,7 +58,7 @@ class TreeNode: # pylint: disable=too-many-instance-attributes
|
|||
def __hash__(self):
|
||||
return hash(self.process)
|
||||
|
||||
def as_snapshot(self): # pylint: disable=too-many-branches
|
||||
def as_snapshot(self): # pylint: disable=too-many-branches,too-many-statements
|
||||
if not isinstance(self.process, Snapshot):
|
||||
with self.process.oneshot():
|
||||
try:
|
||||
|
|
@ -103,6 +103,11 @@ class TreeNode: # pylint: disable=too-many-instance-attributes
|
|||
except host.PsutilError:
|
||||
num_threads = NA
|
||||
|
||||
try:
|
||||
running_time_human = self.process.running_time_human()
|
||||
except host.PsutilError:
|
||||
running_time_human = NA
|
||||
|
||||
self.process = Snapshot(
|
||||
real=self.process,
|
||||
pid=self.process.pid,
|
||||
|
|
@ -113,6 +118,7 @@ class TreeNode: # pylint: disable=too-many-instance-attributes
|
|||
memory_percent=memory_percent,
|
||||
memory_percent_string=memory_percent_string,
|
||||
num_threads=num_threads,
|
||||
running_time_human=running_time_human,
|
||||
)
|
||||
|
||||
if len(self.children) > 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue