From 2270696c8e52cd614c7af6667a9b4cbdb823637c Mon Sep 17 00:00:00 2001 From: Ralph Stevenson-Jones Date: Tue, 16 Jun 2026 11:56:59 +0200 Subject: [PATCH 1/3] limit queue size to 10 images for realtime processing --- pyopia/realtime.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyopia/realtime.py b/pyopia/realtime.py index e0671f3..fd5950a 100644 --- a/pyopia/realtime.py +++ b/pyopia/realtime.py @@ -4,6 +4,7 @@ import logging import pathlib import queue +from collections import deque import threading import time @@ -46,7 +47,7 @@ def _enqueue_file_if_new( return False seen_files.add(file_key) - file_queue.put(file_path) + file_queue.append(file_path) return True @@ -103,8 +104,9 @@ def _worker_loop( ): while not stop_event.is_set(): try: - filepath = file_queue.get(timeout=1) - except queue.Empty: + filepath = file_queue.pop() + except IndexError: + time.sleep(0.1) continue try: @@ -123,8 +125,7 @@ def _worker_loop( finally: with state_lock: runtime_state["current_file"] = "idle" - file_queue.task_done() - + time.sleep(0.1) def run_realtime(pipeline_config: dict, watch_folder: str | None = None): """Run a PyOPIA processing pipeline in realtime by watching a folder. @@ -145,7 +146,7 @@ def run_realtime(pipeline_config: dict, watch_folder: str | None = None): processing_pipeline = pyopia.pipeline.Pipeline(pipeline_config) - file_queue = queue.Queue() + file_queue = deque(maxlen=10) stop_event = threading.Event() seen_files: set[str] = set() seen_lock = threading.Lock() @@ -212,7 +213,6 @@ def run_realtime(pipeline_config: dict, watch_folder: str | None = None): description=( "[blue]Realtime active" f" | processed: {processed_count}" - f" | queued: {file_queue.qsize()}" f" | current: {current_file}" ), ) From 8eb10c758930de4ab75ae7aab03628abe20e4b5b Mon Sep 17 00:00:00 2001 From: Ralph Stevenson-Jones Date: Tue, 16 Jun 2026 12:03:30 +0200 Subject: [PATCH 2/3] fix formatting --- pyopia/realtime.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyopia/realtime.py b/pyopia/realtime.py index fd5950a..5865b16 100644 --- a/pyopia/realtime.py +++ b/pyopia/realtime.py @@ -127,6 +127,7 @@ def _worker_loop( runtime_state["current_file"] = "idle" time.sleep(0.1) + def run_realtime(pipeline_config: dict, watch_folder: str | None = None): """Run a PyOPIA processing pipeline in realtime by watching a folder. From 2c9eba541dab95fc57db62291f25062c431513a9 Mon Sep 17 00:00:00 2001 From: Ralph Stevenson-Jones Date: Tue, 16 Jun 2026 12:23:21 +0200 Subject: [PATCH 3/3] bump version --- pyopia/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyopia/__init__.py b/pyopia/__init__.py index ab9fae3..c4ed6cf 100644 --- a/pyopia/__init__.py +++ b/pyopia/__init__.py @@ -1 +1 @@ -__version__ = "2.16.5" +__version__ = "2.16.6"