From 4a9cdefa4a3db26c784e9f84d59d01e0dc46b781 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Fri, 18 Feb 2022 01:48:19 -0500 Subject: [PATCH] BUGFIG bot - Doesn't close properly --- op25Handler.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/op25Handler.py b/op25Handler.py index eff1cfb..29e0dc4 100644 --- a/op25Handler.py +++ b/op25Handler.py @@ -1,5 +1,6 @@ import threading import subprocess +import time import os @@ -37,6 +38,14 @@ class OP25Handler(threading.Thread): print(f"Closing OP25") try: self.OP25Proc.kill() - self.OP25Proc.terminate() + + seconds_waited = 0 + while self.OP25Proc.poll() is None: + # Terminate the process every 5 seconds + if seconds_waited % 5 == 0: + self.OP25Proc.terminate() + time.sleep(1) + seconds_waited += 1 + except Exception as e: print(e)