giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.38k forks source link

[macOS] Plagued by ZombieProcesses #1765

Closed michaelaye closed 4 years ago

michaelaye commented 4 years ago

Platform

Bug description When using Jupyterlab I am currently plagued by psutil.ZombieProcess raisings, (maybe similar to #1044 ? ):

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_common.py", line 449, in wrapper
    ret = self._cache[fun]
AttributeError: _cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 352, in catch_zombie
    yield
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 393, in _get_pidtaskinfo
    ret = cext.proc_pidtaskinfo_oneshot(self.pid)
ProcessLookupError: [Errno 3] No such process (originated from proc_pidinfo())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/tornado/ioloop.py", line 767, in _discard_future_result
    future.result()
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/tornado/gen.py", line 191, in wrapper
    result = func(*args, **kwargs)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/nbresuse/prometheus.py", line 34, in __call__
    metrics = self.apply_memory_limits(memory_metrics())
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/nbresuse/metrics.py", line 24, in memory_metrics
    rss = sum([p.memory_info().rss for p in all_processes])
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/nbresuse/metrics.py", line 24, in <listcomp>
    rss = sum([p.memory_info().rss for p in all_processes])
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_common.py", line 452, in wrapper
    return fun(self)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/__init__.py", line 1070, in memory_info
    return self._proc.memory_info()
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 334, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 462, in memory_info
    rawtuple = self._get_pidtaskinfo()
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 334, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_common.py", line 452, in wrapper
    return fun(self)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 393, in _get_pidtaskinfo
    ret = cext.proc_pidtaskinfo_oneshot(self.pid)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_psosx.py", line 363, in catch_zombie
    raise ZombieProcess(proc.pid, proc._name, proc._ppid)
psutil.ZombieProcess: psutil.ZombieProcess process still exists but it's a zombie (pid=90915)
LabApp - ERROR - Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x10fd47790>>, <Future finished exception=psutil.ZombieProcess process still exists but it's a zombie (pid=91336)>)
Traceback (most recent call last):
  File "/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/psutil/_common.py", line 449, in wrapper
    ret = self._cache[fun]
AttributeError: 'Process' object has no attribute '_cache

after this the same error loop starts.

Test results { output of python -c psutil.tests (failures only, not full result) }

$ python -c "import psutil; psutil.tests()"                                               
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'psutil' has no attribute 'tests'
giampaolo commented 4 years ago

What does this code do? Also, ZombieProcess is a legitimate exception... if the process is a zombie. Is it? You can check with proc.status() == "zombie".

michaelaye commented 4 years ago

I don’t know what this does, it just appears in my Jupyter lab console. I guess I will report there.