fix: gracefully handle disappearing procs#27
Conversation
…tween versions of job-getter funcs by combining them
altendky
left a comment
There was a problem hiding this comment.
Note that I'm not checking completeness of the refactor. There may be leftover references to the removed function. Normally tests with coverage checks would account for that (mostly).
Approving despite suggestions since the suggestions aren't obviously significantly better. But maybe still of interest.
Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
altendky
left a comment
There was a problem hiding this comment.
Sorry, the benefit of using an empty iterable as the default was to eliminate the special case handling code of when it was None. Just makes it a tad easier to read. Especially the second if where the and short-circuit was being leveraged to avoid accessing a not-defined variable. (where I think both the maybe-defined variable and the short-circuit dependency are a bit smelly individually)
| if cached_jobs: | ||
| cached_jobs_by_pid = { j.proc.pid: j for j in cached_jobs } |
There was a problem hiding this comment.
| if cached_jobs: | |
| cached_jobs_by_pid = { j.proc.pid: j for j in cached_jobs } | |
| cached_jobs_by_pid = { j.proc.pid: j for j in cached_jobs } |
| # iteration and data access. | ||
| with contextlib.suppress(psutil.NoSuchProcess): | ||
| if is_plotting_cmdline(proc.cmdline()): | ||
| if cached_jobs and proc.pid in cached_jobs_by_pid.keys(): |
There was a problem hiding this comment.
| if cached_jobs and proc.pid in cached_jobs_by_pid.keys(): | |
| if proc.pid in cached_jobs_by_pid.keys(): |
and fix inconsistencies between versions of job-getter funcs by combining them