diff options
Diffstat (limited to 'app/backends/qwen.py')
| -rw-r--r-- | app/backends/qwen.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/backends/qwen.py b/app/backends/qwen.py index b2a1df4..4f3afd9 100644 --- a/app/backends/qwen.py +++ b/app/backends/qwen.py @@ -457,6 +457,33 @@ def uninstall(*, emit=None, cancel=None) -> int: return rc +def update(*, emit=None, cancel=None) -> int: + """Update the qwen-tts backend: pip install -U qwen-tts in its venv. + + A managed server that is running is stopped first (best-effort): it + imports ``qwen_tts`` from the very venv being upgraded, so an in-place + upgrade under a live process would leave it serving stale code. + CANCEL is a ``threading.Event`` honored between phases only (stop + server / pip) — a started phase always completes, so pip is never + killed mid-run. pip itself is the freshness check: it resolves the + latest version, upgrades when there is one, and reports "Requirement + already satisfied" otherwise. Returns the exit code (130 when + cancelled before a remaining phase). + """ + if servers.pid_for("qwen") is not None: + servers.stop("qwen") + if common.cancel_requested(cancel): + return 130 + rc = common.pip_install([QWEN_PIP_PKG], emit=emit, cancel=cancel, + env_dir=QWEN_ENV, upgrade=True) + if rc != 0: + print(f"[WARNING] pip install -U failed (exit {rc}); update " + f"{QWEN_PIP_PKG} manually") + else: + print(f"[OK] {QWEN_PIP_PKG} is up to date (or just upgraded).") + return rc + + def models_screen(stdscr) -> int: """Per-model (un)install screen: the hub's Configure-qwen-tts leaf. |
