From 6894e626a93dc18c879cee2bf7e1a4e6264ba506 Mon Sep 17 00:00:00 2001 From: Smittix Date: Tue, 24 Feb 2026 16:16:52 +0000 Subject: [PATCH] Fix WeFax image not appearing in gallery after stop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stop() was returning before the decode thread could save any partial image to disk, so the frontend loadImages() call found nothing new. Join the decode thread (2s timeout) before returning — with select()- based reads the thread exits within ~0.5s so this stays responsive. Co-Authored-By: Claude Opus 4.6 --- utils/wefax.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/wefax.py b/utils/wefax.py index cf83b3e..cf457d3 100644 --- a/utils/wefax.py +++ b/utils/wefax.py @@ -686,19 +686,26 @@ class WeFaxDecoder: def stop(self) -> None: """Stop WeFax decoder. - Non-blocking: sets _running=False and terminates the process, - then returns immediately. The decode thread handles cleanup - when its read() returns empty. + Sets _running=False and terminates the process outside the lock, + then waits briefly for the decode thread to finish saving any + partial image before returning. """ with self._lock: self._running = False proc = self._rtl_process self._rtl_process = None + thread = self._decode_thread if proc: with contextlib.suppress(Exception): proc.terminate() + # Wait for the decode thread to save any partial image. + # With select()-based reads the thread exits within ~0.5s. + if thread: + with contextlib.suppress(Exception): + thread.join(timeout=2) + logger.info("WeFax decoder stopped") def get_images(self) -> list[WeFaxImage]: