'why i cant terminate my process via subprocess terminate?

What's wrong with my code?

I can't terminate my proc

class variables:
    var_bhop = IntVar()
    proc_bhop = None

def fbhop():
    if variables.var_bhop.get() == 1:
        variables.proc_bhop = Popen('py BHop.py', cwd='utils', shell= True)
    else:
        variables.proc_bhop.terminate()

I tried all the ways I knew

But none of them worked

Class, Global key, Change statement from else to elif and second if

And you need to know that I use Tkinter for my application GUI



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source