aboutsummaryrefslogtreecommitdiff
path: root/app/backends/qwen.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/backends/qwen.py')
-rw-r--r--app/backends/qwen.py16
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")