This commit is contained in:
Nicolas Mowen 2025-11-03 15:38:46 -07:00
parent 2e0c38c29e
commit f651d1ee94

View File

@ -378,26 +378,15 @@ class RemoteObjectDetector:
if self.stop_event.is_set():
return detections
# Drain any stale notifications from the ZMQ buffer before making a new request
# Drain any stale detection results from the ZMQ buffer before making a new request
# This prevents reading detection results from a previous request
stale_count = 0
# NOTE: This should never happen, but can in some rare cases
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}"
)
self.detector_subscriber.socket.recv_string(flags=zmq.NOBLOCK)
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
self.np_shm[:] = tensor_input[:]
self.detection_queue.put(self.name)