mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-19 06:40:38 -07:00
Review fixes: CUDA restore in finally, os._exit on Windows, taskkill /T for process tree, build-server-cuda error handling, db-init path
This commit is contained in:
+12
-11
@@ -168,17 +168,18 @@ def build_server(cuda=False):
|
||||
restore_cuda = True
|
||||
|
||||
# Run PyInstaller
|
||||
PyInstaller.__main__.run(args)
|
||||
|
||||
# Restore CUDA torch if we swapped it out
|
||||
if restore_cuda:
|
||||
print("Restoring CUDA torch...")
|
||||
import subprocess
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "torch", "torchvision", "torchaudio",
|
||||
"--index-url", "https://download.pytorch.org/whl/cu126", "--force-reinstall", "-q"],
|
||||
check=True
|
||||
)
|
||||
try:
|
||||
PyInstaller.__main__.run(args)
|
||||
finally:
|
||||
# Restore CUDA torch if we swapped it out (even on build failure)
|
||||
if restore_cuda:
|
||||
print("Restoring CUDA torch...")
|
||||
import subprocess
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "torch", "torchvision", "torchaudio",
|
||||
"--index-url", "https://download.pytorch.org/whl/cu126", "--force-reinstall", "-q"],
|
||||
check=True
|
||||
)
|
||||
|
||||
print(f"Binary built in {backend_dir / 'dist' / binary_name}")
|
||||
|
||||
|
||||
+7
-1
@@ -119,7 +119,13 @@ def _start_parent_watchdog(parent_pid, data_dir=None):
|
||||
while True:
|
||||
if not _is_pid_alive(parent_pid):
|
||||
watchdog_logger.info(f"Parent process {parent_pid} gone, shutting down server...")
|
||||
os.kill(os.getpid(), signal.SIGTERM)
|
||||
if sys.platform == "win32":
|
||||
# sys.exit triggers SystemExit, allowing uvicorn to run
|
||||
# shutdown handlers. os.kill(SIGTERM) on Windows calls
|
||||
# TerminateProcess which hard-kills without cleanup.
|
||||
os._exit(0)
|
||||
else:
|
||||
os.kill(os.getpid(), signal.SIGTERM)
|
||||
return
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user