From d2cd9f6a2b0a292715368b97f488f0bab3d2b4a9 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 26 Nov 2024 19:48:00 +0100 Subject: [PATCH] fix empty queue --- wigglecam/services/backends/cameras/virtualcamera.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wigglecam/services/backends/cameras/virtualcamera.py b/wigglecam/services/backends/cameras/virtualcamera.py index 7e352f0..6874c4f 100644 --- a/wigglecam/services/backends/cameras/virtualcamera.py +++ b/wigglecam/services/backends/cameras/virtualcamera.py @@ -2,7 +2,7 @@ import logging import random import time -from queue import Full, Queue +from queue import Empty, Full, Queue from threading import BrokenBarrierError, Condition, current_thread import numpy @@ -160,7 +160,12 @@ def _camera_fun(self): while not current_thread().stopped(): # adjust_amount_clamped = 0 - img, timestamp_exposure_start = self._producer_queue.get(block=True, timeout=1) + try: + img, timestamp_exposure_start = self._producer_queue.get(block=True, timeout=1) + except Empty: + # if producer did not yet produce something, because thread started delayed, we just continue + continue + self._current_timestampset.camera = timestamp_exposure_start with self._data_condition: