swar / Swar-Chia-Plot-Manager

This is a Cross-Platform Plot Manager for Chia Plotting that is simple, easy-to-use, and reliable.
GNU General Public License v3.0
1.25k stars 388 forks source link

There seems to be a bug in detecting the zombie process #1271

Open fanisky opened 3 years ago

fanisky commented 3 years ago

It doesn't happen every time, but it happens every day, causing the main program to exit

Code file: stateless-manager.py

Occurrence code line: if psutil.Process(pid).status() != 'zombie':

Code snippet:

    logging.info(f'Clearing zombies')

    for job in jobs:
        non_zombie_work = []
        for pid in job.running_work:
            if psutil.Process(pid).status() != 'zombie':
                non_zombie_work.append(pid)
            else:
                del running_work[pid]
                job.total_running = job.total_running - 1

        job.running_work = non_zombie_work

Debug file:

 Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\psutil\_pswindows.py", line 679, in wrapper
    return fun(self, *args, **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\psutil\_pswindows.py", line 1054, in status
    suspended = cext.proc_is_suspended(self.pid)
ProcessLookupError: [Errno 3] assume no such process (originated from NtQuerySystemInformation (no PID found))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\auto-chia\Swar-Chia-Plot-Manager-main\stateless-manager.py", line 99, in <module>
    if psutil.Process(pid).status() != 'zombie':
  File "C:\Program Files\Python37\lib\site-packages\psutil\__init__.py", line 682, in status
    return self._proc.status()
  File "C:\Program Files\Python37\lib\site-packages\psutil\_pswindows.py", line 681, in wrapper
    raise convert_oserror(err, pid=self.pid, name=self._name)
psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=12184)
fanisky commented 3 years ago

Exception should be caught. Or first determine whether the process number exists?