-
Notifications
You must be signed in to change notification settings - Fork 184
[9.0] Subprocess: use psutil for killing processes #8359
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
c5358e5 to
c6b2e6a
Compare
c6b2e6a to
8414d02
Compare
ec23535 to
72f644d
Compare
| for p in children: | ||
| g, a = self.__terminateProcess(p) |
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.
Actually here you could directly call psutil.wait_procs as it was done before, no?
This is shown in the psutil documentation (https://psutil.readthedocs.io/en/latest/index.html#psutil.wait_procs) and this was done like this before (I think the else block was correct but it was just not used by the JobWrapper.
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.
Well actually, forget about my other comment: any reason for not applying this 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.
The 2 are not equivalent?
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.
Sorry I should have provided further details.
Here you sequentially terminate and wait for each process to terminate. If there are n processes, and if they do not terminate, you are going to wait for n * 60s from what I understand.
Whereas you could reduce the waiting time from o(n) to o(1) by doing:
for p in children:
p.terminate()
psutil.wait_procs(children, timeout=60)This is what it's currently done and what is recommended in the documentation.
(The problem with the current code is the first bloc after the if pgid != os.getpgrp():, because we terminate the processes but we don't kill them I think, the else bloc looks fine to me).
72f644d to
82e0985
Compare
82e0985 to
b3872ff
Compare
This is a rewrite of few functions in subprocess that need very careful evaluation.
For reasons not understood (at least not by me) the logic of killing a pid and its sub-processes is not completing (not always, at least). I blame the very old logic used there, but of course I might be wrong. In any case this is a rewriting using
psutil.I had to change one test in Test_JobWrapper. I have not fully understood why, but I do not see how the previous code could work. cc @aldbr
BEGINRELEASENOTES
CHANGE: Subprocess: use psutil for killing processes
ENDRELEASENOTES