Properly catch permission issues
astrofrog opened this issue · 0 comments
astrofrog commented
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 <module>
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).