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
This occurred to me while debugging #1152. It would be extremely useful to be able to run psutil in DEBUG mode and print useful messages on stderr in order to debug nasty issues. In order to use it one would have to start python like this:
PSUTIL_DEBUG=1 python script.py
On Windows:
set PSUTIL_DEBUG=1 && C:\Python36\python.exe script.py
Something like this will likely be used only for error conditions, before raising an exception, and never for informational logging. Currently if a C function body has 2 syscalls, both raising OSError, the Python exception does not tell you which one failed. With this in place we can do:
if (! syscall1()) {
debug("syscall1 failed");
returnPyErr_SetFromErrno(PyExc_OSError);
}
if (! syscall2()) {
debug("syscall2 failed");
returnPyErr_SetFromErrno(PyExc_OSError);
}
...and the traceback will look like this:
psutil-debug> syscall2 failed
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: 'foo'
This will make users able to submit better reports on the bug tracker. Unit tests and CI services will likely have PSUTIL_DEBUG enabled by default for the same reason.
The text was updated successfully, but these errors were encountered:
This occurred to me while debugging #1152. It would be extremely useful to be able to run psutil in DEBUG mode and print useful messages on stderr in order to debug nasty issues. In order to use it one would have to start python like this:
On Windows:
Something like this will likely be used only for error conditions, before raising an exception, and never for informational logging. Currently if a C function body has 2 syscalls, both raising
OSError
, the Python exception does not tell you which one failed. With this in place we can do:...and the traceback will look like this:
This will make users able to submit better reports on the bug tracker. Unit tests and CI services will likely have PSUTIL_DEBUG enabled by default for the same reason.
The text was updated successfully, but these errors were encountered: