👍️[Update] Model : Watchdog timerの終了処理をmain loopの終了処理に変更

This commit is contained in:
misyaguziya
2024-09-27 01:02:20 +09:00
parent 71225bf045
commit a0407afa54
6 changed files with 35 additions and 26 deletions

View File

@@ -319,6 +319,7 @@ mapping = {
class Main:
def __init__(self) -> None:
self.queue = Queue()
self.main_loop = True
def receiver(self) -> None:
while True:
@@ -380,15 +381,19 @@ class Main:
th_handler.daemon = True
th_handler.start()
def loop(self) -> None:
while True:
def start(self) -> None:
while self.main_loop:
time.sleep(1)
def stop(self) -> None:
self.main_loop = False
if __name__ == "__main__":
main = Main()
main.startReceiver()
main.startHandler()
controller.setWatchdogCallback(main.stop)
controller.init()
# mappingのすべてのstatusをTrueにする
@@ -398,7 +403,7 @@ if __name__ == "__main__":
process = "main"
match process:
case "main":
main.loop()
main.start()
case "test":
for _ in range(100):