diff options
| author | historia <historiavg@proton.me> | 2026-08-25 18:10:08 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-25 18:10:08 -0400 |
| commit | 4b49797b4d57c2d2cf63472636622a7a6280a38e (patch) | |
| tree | e3687c734de5d6159cdad288e025057ed6cd3a16 /app/backends/qwen.py | |
| parent | bcac6c42eaf9e004716d72960bddefb1db68a93c (diff) | |
| download | tts-audiobook-generator-4b49797b4d57c2d2cf63472636622a7a6280a38e.tar.gz | |
feat: no console drop when uninstalling backends
Diffstat (limited to 'app/backends/qwen.py')
| -rw-r--r-- | app/backends/qwen.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/backends/qwen.py b/app/backends/qwen.py index be7ebfe..c6a11bf 100644 --- a/app/backends/qwen.py +++ b/app/backends/qwen.py @@ -354,17 +354,25 @@ def _detect_remote(managed: bool = False): return remote_models, remote_urls -def uninstall() -> int: +def uninstall(*, emit=None, cancel=None) -> int: """Remove the qwen-tts backend entirely: stop its servers, pip uninstall. qwen-tts is a pip package (``qwen_tts`` + the ``qwen-tts-demo`` script) installed into the managed venv, so uninstalling it removes the backend. - Any server this tool started is stopped first (best-effort). Returns the - exit code. + Any server this tool started is stopped first (best-effort). + + With EMIT given (the in-TUI task view) pip runs piped, streaming into + EMIT, so its output never touches the terminal behind curses. CANCEL is + a ``threading.Event`` honored between phases only (after the servers + have been stopped, before pip starts) — a started phase always completes, + so pip is never killed mid-run. Returns the exit code (130 when + cancelled before pip ran). """ servers.stop("qwen-custom") servers.stop("qwen-clone") - rc = common.pip_uninstall([QWEN_PIP_PKG]) + if common.cancel_requested(cancel): + return 130 + rc = common.pip_uninstall([QWEN_PIP_PKG], emit=emit) if rc != 0: print(f"[WARNING] pip uninstall failed (exit {rc}); remove " f"{QWEN_PIP_PKG} from the managed venv manually") |
