From within my python script, I want to start another python script which will run in the background waiting for the instruction to terminate.
- Host Python script (H1) starts subprocess P1.
- P1 performs some short lived work & returns a sentinel to indicate that it is now going to sleep awaiting instructions to terminate.
- H1 polls for this sentinel repeatedly. When it receives the sentinel, it performs some other IO bound task and when that completes, tells P1 to die gracefully (meaning close any resources that you have acquired).
Is this feasible to do with the subprocess module ?
Output: