mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 05:24:11 +03:00
Catch case where detector overflows
This commit is contained in:
parent
7aac6b4f21
commit
be94e9ae78
@ -9,6 +9,7 @@ from multiprocessing import Queue, Value
|
|||||||
from multiprocessing.synchronize import Event as MpEvent
|
from multiprocessing.synchronize import Event as MpEvent
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import zmq
|
||||||
|
|
||||||
from frigate.comms.object_detector_signaler import (
|
from frigate.comms.object_detector_signaler import (
|
||||||
ObjectDetectorPublisher,
|
ObjectDetectorPublisher,
|
||||||
@ -377,6 +378,26 @@ class RemoteObjectDetector:
|
|||||||
if self.stop_event.is_set():
|
if self.stop_event.is_set():
|
||||||
return detections
|
return detections
|
||||||
|
|
||||||
|
# Drain any stale notifications from the ZMQ buffer before making a new request
|
||||||
|
# This prevents reading detection results from a previous request
|
||||||
|
stale_count = 0
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
stale_msg = self.detector_subscriber.socket.recv_string(
|
||||||
|
flags=zmq.NOBLOCK
|
||||||
|
)
|
||||||
|
stale_count += 1
|
||||||
|
logger.warning(
|
||||||
|
f"{self.name}: Drained stale notification #{stale_count}: {stale_msg}"
|
||||||
|
)
|
||||||
|
except zmq.Again:
|
||||||
|
break
|
||||||
|
|
||||||
|
if stale_count > 0:
|
||||||
|
logger.warning(
|
||||||
|
f"{self.name}: Drained {stale_count} stale notification(s) before new detection request"
|
||||||
|
)
|
||||||
|
|
||||||
# copy input to shared memory
|
# copy input to shared memory
|
||||||
self.np_shm[:] = tensor_input[:]
|
self.np_shm[:] = tensor_input[:]
|
||||||
self.detection_queue.put(self.name)
|
self.detection_queue.put(self.name)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user