You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
======================================================================
ERROR: psutil.tests.test_contracts.TestFetchAllProcesses.test_all
----------------------------------------------------------------------
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/lib/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/vagrant/psutil/psutil/tests/test_contracts.py", line 389, in proc_info
info[fun_name] = fun()
File "/vagrant/psutil/psutil/__init__.py", line 719, in cwd
return self._proc.cwd()
File "/vagrant/psutil/psutil/_psbsd.py", line 566, in wrapper
return fun(self, *args, **kwargs)
File "/vagrant/psutil/psutil/_psbsd.py", line 842, in cwd
return cext.proc_cwd(self.pid) or None
FileNotFoundError: [Errno 2] No such file or directory
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/vagrant/psutil/psutil/tests/test_contracts.py", line 431, in test_all
for info in self.iter_proc_info():
File "/usr/local/lib/python3.8/multiprocessing/pool.py", line 868, in next
raise value
FileNotFoundError: [Errno 2] No such file or directory
psutil.Process(pid=63428, name='bash', status='sleeping', started='15:30:39')
Traceback (most recent call last):
File "foo.py", line 6, in <module>
print(p.cwd())
File "/vagrant/psutil/psutil/__init__.py", line 719, in cwd
return self._proc.cwd()
File "/vagrant/psutil/psutil/_psbsd.py", line 566, in wrapper
return fun(self, *args, **kwargs)
File "/vagrant/psutil/psutil/_psbsd.py", line 842, in cwd
return cext.proc_cwd(self.pid) or None
FileNotFoundError: [Errno 2] No such file or directory
Not sure why this happens. Probably the directory was deleted and internally the kernel calls stat() against it. Regardless, it should not crash with FileNotFoundError. Even though not documented, there are circumstances where we return None if cwd() cannot be determined (BSD*, AIX, SunOS), so we should do the same here.
EDIT: despite not directly cached in unit tests, the same problem can also occur on NetBSD.
The text was updated successfully, but these errors were encountered:
giampaolo
changed the title
[OpenBSD] Process cwd() can raise FileNotFoundError
[OpenBSD], [NetBSD] Process cwd() can raise FileNotFoundError
Apr 16, 2023
* 'master' of https://github.com/giampaolo/psutil: (22 commits)
use glob.glob() in setup.py
OSX / refact: get rid of process_info.c (giampaolo#2243)
OSX C refact: reconstruct _psutil_osx.c to preserve history
OSX: rename psutil/_psutil_osx.c to arch/osx/proc.c to preserve GIT history
OSX big C refactoring (giampaolo#2242)
fix failing users() test; update HISTORY; give CREDITS to @0-wiz-0 for giampaolo#2241
win C refact: reconstruct _psutil_windows.c trying to preserve history
rename _psutil_windows.c -> proc.c
Win, C, refact: move proc funcs into proc.c file
BSD big refact: move proc funcs in new proc.c file
Fix build on NetBSD due to missing .h include. (giampaolo#2241)
Win, C, refact: move boot_time() and users() in new sys.c
Windows / refact: new sensors.c file
C refact: remove useless cmdline / cwd / environ layers. Call direct functions
pre release
Add CI testing for OpenBSD and NetBSD (giampaolo#2240)
Fixgiampaolo#2239 / proc name(): don't fail with ZombieProcess on cmdline()
giampaolo#2238: passed wrong value to Py_BuildValue
fixgiampaolo#2238 if cwd() cannot be determined always return "" instead of None
Fixgiampaolo#2237, OpenBSD, cwd(): return None instead of FileNotFoundError
...
Summary
Description
Observed in unit tests:
Also reproducible with:
...which prints:
Not sure why this happens. Probably the directory was deleted and internally the kernel calls
stat()
against it. Regardless, it should not crash withFileNotFoundError
. Even though not documented, there are circumstances where we returnNone
if cwd() cannot be determined (BSD*, AIX, SunOS), so we should do the same here.EDIT: despite not directly cached in unit tests, the same problem can also occur on NetBSD.
The text was updated successfully, but these errors were encountered: