0

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?

Gil.I
  • 895
  • 12
  • 23

1 Answers1

0

You should be able to use something like this solution to identify and terminate the subprocesses launched by the application to run tests. This solution seems to particularly fit your use case of killing all background processes in order to allow your application to run more tests.

Alternatively, you may be able to create a try-except wrapper or decorator for your tests that allow them to be killed when sent a certain signal is sent by the application, but this requires the application to keep track of all initiated subprocesses and may fail to properly kill all processes if the tests launch additional subprocesses in the background.

lcary
  • 393
  • 2
  • 13