My python script calls another python scripts method (which runs an infinite loop and performs some activity) and runs it as thread. I want to kill my calling python script as soon as the thread dies
- Make the other python script add '1' to a txt when it's done, and then put a while loop in the original, and once it detects the '1', then end the programwhackamadoodle3000– whackamadoodle30002018-06-29 06:09:57 +00:00Commented Jun 29, 2018 at 6:09
- my called python script runs an infinite loop. It cannot end. if it gets killed somehow then I want to terminate parentLazyCoder– LazyCoder2018-06-29 07:00:58 +00:00Commented Jun 29, 2018 at 7:00
Add a comment |
1 Answer
Are you using the module threading? If so, you could periodically check the status of your thread via the method threading.is_alive().
If your infinite thread is killed somehow, your permanently checking main thread (possibly notified by another thread initialized like this) can also terminate.