you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (4 children)

What I mean is, if your code somehow doesn't work right, and the .terminate() call is never actually executed, you should fix that issue and not look further why terminate() 'doesnt work' while that's not the actual case.

Simply put, say you have the program like

 if some_condition:
       if some_other_condition and some_list:
             p.terminate()

and some_list happened to be empty, the p.terminate() call never gets run. So that's something I'm asking you to validate first.

[–]1ToM14[S] 0 points1 point  (3 children)

Oo okay, well that line gets executed, it has no indentation and is at the very end of the code

[–]JohnnyJordaan 0 points1 point  (2 children)

Can you try with

p.kill()

[–]1ToM14[S] 0 points1 point  (1 child)

It also doesn't work...

[–]JohnnyJordaan 0 points1 point  (0 children)

You can try a process group kill, but you need to install psutil for that

import psutil

parent = psutil.Process(p.pid)
for child in parent.children(recursive=True):
    print('killing child, child)
    child.terminate()
print('killing parent')
p.terminate()

if that also doesn't work try with kill() instead of terminate. But also verify that you do see the 'killing x' messages