-
Notifications
You must be signed in to change notification settings - Fork 186
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
Kill descendant processes in core.direct
schedulers plugin
#6572
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -354,9 +354,18 @@ def _parse_submit_output(self, retval, stdout, stderr): | |||||
|
||||||
return stdout.strip() | ||||||
|
||||||
def _get_kill_command(self, jobid): | ||||||
"""Return the command to kill the job with specified jobid.""" | ||||||
submit_command = f'kill {jobid}' | ||||||
def _get_kill_command(self, process_id): | ||||||
"""Return the command to kill the process with specified id and all its descendants.""" | ||||||
from psutil import Process | ||||||
|
||||||
# get a list of the process id of all descendants | ||||||
process = Process(int(process_id)) | ||||||
children = process.children(recursive=True) | ||||||
process_ids = [process_id] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should cast to
Suggested change
|
||||||
process_ids.extend([str(child.pid) for child in children]) | ||||||
process_ids_str = ' '.join(process_ids) | ||||||
|
||||||
submit_command = f'kill {process_ids_str}' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a side node: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might as well take the opportunity to fix the variable name
Suggested change
|
||||||
|
||||||
self.logger.info(f'killing job {jobid}') | ||||||
|
||||||
|
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.
By changing
jobid
toprocess_id
you broke the log line on line 370. Either keep it asjobid
or adapt other lines that referenced it accordingly. This would be a breaking change, but since it is an internal method it is ok to change