In Python 3.8.5, if I run psutil.process_iter()
and then iterate through the processes I get an error. Here's some simple code that does it:
import psutil
for proc in psutil.process_iter():
try:
proc.name()
except psutil.ZombieProcess:
pass
The result is ProcessLookupError: [Errno 3] assume no such process (originated from sysctl(KERN_PROCARGS2) -> EINVAL)
. I'm running this on an up-to-date OS X (Monterey 12.5.1). I can simply swallow the error like I do with ZombieProcess
, but I'd like to understand what is going on first and then if there is a more "correct" workaround.
I would recommend debugging a bit further to see if this is caused by a specific proc
for proc in psutil.process_iter():
try:
proc.name()
except psutil.ZombieProcess:
print(proc)
pass
Proc usually prints out status
I'm not sure if you're sure you have a zombie process or if you're checking for one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.