mirror of
https://github.com/smittix/intercept.git
synced 2026-04-30 09:39:58 -07:00
Fix WeFax image not appearing in gallery after stop
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 <noreply@anthropic.com>
This commit is contained in:
@@ -686,19 +686,26 @@ class WeFaxDecoder:
|
|||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
"""Stop WeFax decoder.
|
"""Stop WeFax decoder.
|
||||||
|
|
||||||
Non-blocking: sets _running=False and terminates the process,
|
Sets _running=False and terminates the process outside the lock,
|
||||||
then returns immediately. The decode thread handles cleanup
|
then waits briefly for the decode thread to finish saving any
|
||||||
when its read() returns empty.
|
partial image before returning.
|
||||||
"""
|
"""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self._running = False
|
self._running = False
|
||||||
proc = self._rtl_process
|
proc = self._rtl_process
|
||||||
self._rtl_process = None
|
self._rtl_process = None
|
||||||
|
thread = self._decode_thread
|
||||||
|
|
||||||
if proc:
|
if proc:
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
proc.terminate()
|
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")
|
logger.info("WeFax decoder stopped")
|
||||||
|
|
||||||
def get_images(self) -> list[WeFaxImage]:
|
def get_images(self) -> list[WeFaxImage]:
|
||||||
|
|||||||
Reference in New Issue
Block a user