-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Linux/Android] Handle case when no access to /proc/stats #1334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unfortunately there is nothing that psutil can do about it. Raising |
But it's not raising AccessDenied. It's printing that exception using traceback in global exception handler. My suggestion is to silently ignore AccessDenied. https://github.com/giampaolo/psutil/blob/master/psutil/_pslinux.py#L332 |
I find it hard to understand the traceback from my phone. Please paste the error as pure text. |
|
I suppressed the message suppressed occurring at import time in 2e220c8. As such the exception will actually occur (and bubble up) on the first call to |
|
I also experience this often in my own program. I'm not sure which library I'm using is calling psutil but I also don't expect the many downstream library maintainers to each handle Android as a special case in every place that they use psutil
|
"PermissionError: [Errno 13] Permission denied: '/proc/stat'" Note that this happens on |
try:
read_proc_stat
except PermissionError:
is_android = any([k in os.environ for k in ['ANDROID_STORAGE']])
if is_android:
pass # expected on this platform
else:
raise e I don't know what process statistics are used for but it might make even more sense to do something like this: try:
value = read_proc_stat
except PermissionError as e:
value = 'Permission Denied'
else:
return value |
comment fieds witch contain raise |
@giampaolo so can the traceback be not printed for this too? Line 288 in 49aba75
Or is this is too important to ignore on other platforms then detect if it is android and don't print traceback in android? |
Android Oreo prohibited access to some info from proc. Likely it's worth to handle such cases without explicit exceptions.
The text was updated successfully, but these errors were encountered: