I'd like to use Python to run some Windows .bat files which would call some commercial .exe software.
However, the commercial software will likely take a long time to finish or get stuck. If the software completes, it would quit itself automatically. Otherwise it'll stay open indefinitely. This may be used as an indicator of completeness for simplicity (although not 100% guarantee) as I don't know how to get some success return code status if the software successfully completes its job.
I want the Python script to retry running the commercial software if it doesn't finish after say 30 mins. The software needs to be terminated before retrying, if it is reopened before being terminated, there would be error.
My attempt:
Use Python threading to create a thread for each running of a .bat calling the commercial software. The starting of the bat is done by os.system('<pathname>\<batfilename> <arguments needed>')
The mother thread would measure the time elapsed by the child thread and if it exceeds 30 mins, then the mother thread would terminate the thread and start it again.
However, I'm not sure if the termination of the thread would cause the software to close. I also do not know how to measure the time taken while the thread is still running as I see most codes online are about joining which needs the child thread to finish and they are measuring the finish_time - start_time. But here the software would still be running when stuck