Mar-16-2024, 11:16 AM
Dear,
I want to stop my python program by a bash script normally so i have these code:
Thank you for your answers.
I want to stop my python program by a bash script normally so i have these code:
from time import sleep import sys import os import threading from _thread import interrupt_main from timed_count import timed_count class MyThreadReadUpdate (threading.Thread): def __init__(self): threading.Thread.__init__(self) self._running = True def terminate(self): self._running = False def run(self): while self._running: #print("MyThreadReadUpdate is running") if os.path.exists(sys.argv[2]): f3 = open(sys.argv[2], "r+") valueToDo=f3.readline().rstrip() #print(valueToDo+"/") if (valueToDo == "Close" ): print("Exiting program is asked by user") sleep(2) f3.seek(0); f3.write("Nothing") f3.close() sys.exit(0) else: #print("run always this program") f3.close() #time.sleep(5) readUpdate_Thread = MyThreadReadUpdate() readUpdate_Thread.daemon = True readUpdate_Thread.start() while True: print("loop") sleep(3)So my readUpdate_Thread is kill not my main Thread (while True) .
Thank you for your answers.