diff --git a/frigate/object_detection.py b/frigate/object_detection.py index be5fc36f5..206c47839 100644 --- a/frigate/object_detection.py +++ b/frigate/object_detection.py @@ -88,6 +88,7 @@ def run_detector( stop_event = mp.Event() def receiveSignal(signalNumber, frame): + logger.info("Signal to exit detection process...") stop_event.set() signal.signal(signal.SIGTERM, receiveSignal) @@ -125,6 +126,8 @@ def run_detector( avg_speed.value = (avg_speed.value * 9 + duration) / 10 + logger.info("Exited detection process...") + class ObjectDetectProcess: def __init__( @@ -144,6 +147,9 @@ class ObjectDetectProcess: self.start_or_restart() def stop(self): + # if the process has already exited on its own, just return + if self.detect_process and self.detect_process.exitcode: + return self.detect_process.terminate() logging.info("Waiting for detection process to exit gracefully...") self.detect_process.join(timeout=30) @@ -151,6 +157,7 @@ class ObjectDetectProcess: logging.info("Detection process didnt exit. Force killing...") self.detect_process.kill() self.detect_process.join() + logging.info("Detection process has exited...") def start_or_restart(self): self.detection_start.value = 0.0