-
Notifications
You must be signed in to change notification settings - Fork 11
Add wrapper for catching FileNotFound Exception #87
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
Conversation
|
@Jongy please review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done reviewing :) Also please note the linting failures.
| pid_max = int(pid_max_file.read()) | ||
| if pid <= pid_max: | ||
| # Check if pid is running | ||
| if not psutil.pid_exists(pid): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is true though, that pid_exists is a better check than what we have in read_proc_file - we use os.path.exists("/proc/pid"), but this will return True also if pid is a tid of another process (e.g due to reuse). pid_exists uses different means to check, to avoid this confusion. Note @d3dave .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that in read_proc_file we do not want to support PIDs only. I can see value in reading a specific thread's mountinfo, ns/*, stat, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, instead of exists(/proc/pid) should have just kill(pid, 0). (Hmmm, pretty sure I copied that from psutil...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pid_exists does extra checks because they claim os.kill is bad as well :dumb:
Jongy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 more question, and fix linters :)
|
Btw, did you verify that mypy accepts the typing tricks for the decorator? (i.e that |
|
|
Looks good! |
This PR updates granulate-utils post the changes in intel/granulate-utils#73, and includes a few other updates from the utils repo as well, one of them is intel/granulate-utils#87 which fixes #503.
It wraps function get_elf_id(), if that function throws FileNotFound exception then wrapper checks if not found file is /proc/{pid}/*, if it is, wrapper changes exception to NoSuchProcess.
Connected to: intel/gprofiler#503