astrofrog / astrofrog/psrecord

Properly catch permission issues

Open
#31 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
680
Forks
79
PR merge metrics
No merged PRs in 30d

Description

When trying to monitor a root process, one can get the following error:

```
AccessDenied: psutil.AccessDenied (pid=126)
```

in psutil - but in psrecord this shows up as:

```
Traceback (most recent call last):
File "/Users/tom/miniconda3/envs/dev/bin/psrecord", line 7, in
sys.exit(psrecord.main())
File "/Users/tom/miniconda3/envs/dev/lib/python3.6/site-packages/psrecord/main.py", line 109, in main
interval=args.interval, include_children=args.include_children)
File "/Users/tom/miniconda3/envs/dev/lib/python3.6/site-packages/psrecord/main.py", line 218, in monitor
ax.set_ylim(0., max(log['cpu']) * 1.2)
ValueError: max() arg is an empty sequence
```

We should do a better job of propagating the access denied error up (usually indicates sudo should be used).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in psrecord/main.py at main() and monitor(), using the traceback's failing max(log['cpu']) path as the entry point. Reproduce monitoring a root process and verify that the access-denied condition is propagated as an access-denied error rather than an empty-sequence ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.