Fix: [ALAS] Handle psutil.NoSuchProcess

This commit is contained in:
LmeSzinc 2024-06-11 12:44:26 +08:00
parent f02d6ad3af
commit 0a1c0e3dbd
2 changed files with 7 additions and 2 deletions

View File

@ -121,7 +121,10 @@ class DataProcessInfo:
@cached_property @cached_property
def name(self): def name(self):
try:
name = self.proc.name() name = self.proc.name()
except:
name = ''
return name return name
@cached_property @cached_property
@ -130,6 +133,7 @@ class DataProcessInfo:
cmdline = self.proc.cmdline() cmdline = self.proc.cmdline()
except: except:
# psutil.AccessDenied # psutil.AccessDenied
# # NoSuchProcess: process no longer exists (pid=xxx)
cmdline = [] cmdline = []
cmdline = ' '.join(cmdline).replace(r'\\', '/').replace('\\', '/') cmdline = ' '.join(cmdline).replace(r'\\', '/').replace('\\', '/')
return cmdline return cmdline

View File

@ -471,8 +471,9 @@ class EmulatorManager(EmulatorManagerBase):
try: try:
exe = proc.cmdline() exe = proc.cmdline()
exe = exe[0].replace(r'\\', '/').replace('\\', '/') exe = exe[0].replace(r'\\', '/').replace('\\', '/')
except (psutil.AccessDenied, IndexError): except (psutil.AccessDenied, psutil.NoSuchProcess, IndexError):
# psutil.AccessDenied # psutil.AccessDenied
# NoSuchProcess: process no longer exists (pid=xxx)
continue continue
if Emulator.is_emulator(exe): if Emulator.is_emulator(exe):