I have a GUI that run multiple tests files. All the tests are python files that the GUI run one by one using subprocess running from thread.
In the GUI , the user has the ability to stop the machine that run the tests. I already found out how to kill a subprocess for this purpose and its works. see Killing sub process that run inside a thread
Now , I have another issue. The test open lots of instances that I must close in orderly fashion. When I use kill() method , all the instances are not closed and I cant run further tests. I.E the COM port I used in the test before the stop from the user , is still occupied and prevent me to run any more tests.
The only remedy for it, will be closing the GUI and start it over.
In short ,I need a way to kill a subprocess in anytime but still close all the instances like sys.exit() will do or the same effect that closing he GUI has. I've try to use wait(timeout) but unless I'm using it wrongly , it don't do the trick.
Can I use kind of interrupt to the test that will call some method in the test , that will close it in orderly fashion?