I have a Tkinter GUI running two threads, the main tread for the GUI and a worker thread. The worker thread creates a subprocess using the following code:
myProcess = subprocess.Popen(['python', '-u', 'runTests.py'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
The file runTests.py does some setup and then runs a unit test file using the following command:
execfile('myUnitTests.py')
The file myUnitTests.py has several unit tests some that take over five minutes to run. From the GUI I click a button to stop running the tests. This in turn makes the worker thread send a signal to stop the subprocess:
myProcess.terminate()
The terminate command does not stop the process right away, it waits until the current unit test finishes running and then it terminates the process? I have tried to use os.kill but I get the same results as with terminate()
Any idea of how can I make my program more responsive so that it kill the subprocess right away?