Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid more missing process errors #605

Merged
merged 1 commit into from
May 21, 2021
Merged

Conversation

altendky
Copy link
Collaborator

@altendky altendky commented May 21, 2021

I misunderstand https://psutil.readthedocs.io/en/latest/#psutil.Process.oneshot to be a complete cache of all data taken at the time of entering the context manager. As I think about it, this is silly. There's way too much info that would take way too long and the vast majority would be unused in most cases, etc. Nope, it caches data when it, or adjacent tidbits, are requested. Still useful, but doesn't protect against the psutil.NoSuchProcess error.

Traceback (most recent call last):
  File "/farm/venv/lib/python3.9/site-packages/psutil/_common.py", line 447, in wrapper
    ret = self._cache[fun]
KeyError: <function Process.ppid at 0x7fee6029edc0>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/farm/venv/lib/python3.9/site-packages/psutil/_common.py", line 447, in wrapper
    ret = self._cache[fun]
KeyError: <function Process._parse_stat_file at 0x7fee6029a8b0>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/farm/venv/lib/python3.9/site-packages/psutil/_pslinux.py", line 1576, in wrapper
    return fun(self, *args, **kwargs)
  File "/farm/venv/lib/python3.9/site-packages/psutil/_common.py", line 454, in wrapper
    ret = self._cache[fun] = fun(self)
  File "/farm/venv/lib/python3.9/site-packages/psutil/_pslinux.py", line 1618, in _parse_stat_file
    with open_binary("%s/%s/stat" % (self._procfs_path, self.pid)) as f:
  File "/farm/venv/lib/python3.9/site-packages/psutil/_common.py", line 711, in open_binary
    return open(fname, "rb", **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '/proc/9500/stat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chia/.local/bin/plotman", line 33, in <module>
    sys.exit(load_entry_point('plotman', 'console_scripts', 'plotman')())
  File "/farm/plotman/src/plotman/plotman.py", line 179, in main
    interactive.run_interactive()
  File "/farm/plotman/src/plotman/interactive.py", line 335, in run_interactive
    curses.wrapper(curses_main)
  File "/home/chia/.pyenv/versions/3.9.2/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/farm/plotman/src/plotman/interactive.py", line 110, in curses_main
    jobs = Job.get_running_jobs(cfg.directories.log, cached_jobs=jobs)
  File "/farm/plotman/src/plotman/job.py", line 159, in get_running_jobs
    ppids = {process.ppid() for process in processes}
  File "/farm/plotman/src/plotman/job.py", line 159, in <setcomp>
    ppids = {process.ppid() for process in processes}
  File "/farm/venv/lib/python3.9/site-packages/psutil/_common.py", line 454, in wrapper
    ret = self._cache[fun] = fun(self)
  File "/farm/venv/lib/python3.9/site-packages/psutil/__init__.py", line 605, in ppid
    return self._proc.ppid()
  File "/farm/venv/lib/python3.9/site-packages/psutil/_pslinux.py", line 1576, in wrapper
    return fun(self, *args, **kwargs)
  File "/farm/venv/lib/python3.9/site-packages/psutil/_pslinux.py", line 2142, in ppid
    return int(self._parse_stat_file()['ppid'])
  File "/farm/venv/lib/python3.9/site-packages/psutil/_pslinux.py", line 1583, in wrapper
    raise NoSuchProcess(self.pid, self._name)
psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=9500, name='chia')

@altendky altendky merged commit 36caffd into development May 21, 2021
@altendky altendky deleted the altendky-patch-2 branch May 21, 2021 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant