Skip to content Skip to sidebar Skip to footer

Killing All Processes And Threads In Python3.x

I'm writing a UI wrapper for reading some info using esptool.py I have two active threads: UI and procesing - SerialReader. UI class has reference to the SerialReader and should st

Solution 1:

First import os library:

Import os

Then you can write the following code in your exit_event method:

def closeEvent(self, event):  
    output,errors = p1.communicate() 
    bashCommand = "killall python3"
    sudoPassword = 'your password' 
    p = os.system('echo %s|sudo -S %s' % (sudoPassword, bashCommand)) 

Post a Comment for "Killing All Processes And Threads In Python3.x"