mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 22:59:59 -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:
|
||||
"""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]:
|
||||
|
||||
Reference in New Issue
Block a user