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
I'm facing a third-party bug (NVIDIA NVML Python bindings) that returns non-exist PIDs for GPU processes. The PID overflows the C long type limit and raises an OverflowError.
It would be nice if psutil can catch that error and reraise a new exception in a subtype of psutil.Error. For example, if the user passed an extremely large number to psutil.Process(pid), raise a psutil.NoSuchProcess error rather than OverflowError.
Mmm. Yes, I think it makes sense. The error originates from PyArg_ParseTuple (used pretty much everywhere). The Process class can invoke PyArg_ParseTuple on __init__ (hence only once) and turn OverflowError into NoSuchProcess.
The reason why I think this is a good idea is because OverflowError is only raised when invoking C functions. On Linux most of Process APIs are implemented in python instead, by reading /proc, so we do not get OverflowError in those cases (we get NoSuchProcess). As such, making this change would make things more consistent across all platforms, which will always rase NoSuchProcess.
I think it makes sense. The error originates from PyArg_ParseTuple (used pretty much everywhere). The Process class can invoke PyArg_ParseTuple on init (hence only once) and turn OverflowError into NoSuchProcess.
Could we capsule and expose PyArg_ParseTuple(args, _Py_PARSE_PID, &pid) as a function to cext? Then we can call it in Process._init before any cext call.
Summary
Description
I'm facing a third-party bug (NVIDIA NVML Python bindings) that returns non-exist PIDs for GPU processes. The PID overflows the C long type limit and raises an
OverflowError
.It would be nice if
psutil
can catch that error and reraise a new exception in a subtype ofpsutil.Error
. For example, if the user passed an extremely large number topsutil.Process(pid)
, raise apsutil.NoSuchProcess
error rather thanOverflowError
.Reproduce script:
On Windows,
LONG_MAX = 0x7FFFFFFF
(Microsoft C Limits on Integer Constants).Traceback:
The text was updated successfully, but these errors were encountered: