Skip to content

Reliable shutdown on Windows + lelab --stop#46

Open
nobullryder wants to merge 1 commit into
huggingface:mainfrom
nobullryder:launcher-reliability
Open

Reliable shutdown on Windows + lelab --stop#46
nobullryder wants to merge 1 commit into
huggingface:mainfrom
nobullryder:launcher-reliability

Conversation

@nobullryder

Copy link
Copy Markdown

Problem

On Windows, stopping lelab (Ctrl-C / closing the terminal) often leaves the uvicorn and Vite child processes alive, which keeps port :8000 — and any open camera handles — held. The next lelab then fails to bind, or a camera won't open because the previous run never released it.

What this does

  • lelab --stop — finds and terminates a running LeLab and its child process tree, freeing the port.
  • Clean process-tree teardown on exit (psutil, with a Windows taskkill /T fallback) so the uvicorn/Vite children and their handles are actually released.
  • Pre-flight port checks with an actionable message ("…run lelab --stop to free it") instead of an opaque bind error, plus a readiness wait before opening the browser.

Tests

tests/test_scripts_lelab.py covers the stop / teardown / port-check paths with mocked psutil + subprocess (no real processes spawned).

🤖 Generated with Claude Code

On Windows, stopping LeLab (Ctrl-C / closing the terminal) often leaves the
uvicorn and Vite child processes alive, which keeps port :8000 — and any open
camera handles — held. The next `lelab` then fails to bind, or a camera won't
open because the previous run never released it.

- `lelab --stop`: find and terminate a running LeLab and its child process tree,
  freeing the port.
- Clean process-tree teardown on exit (psutil, with a Windows `taskkill /T`
  fallback) so the uvicorn/Vite children and their handles are actually released.
- Pre-flight port checks with an actionable message ("…run `lelab --stop` to free
  it") instead of an opaque bind error, plus a readiness wait before opening the
  browser.

Tests in tests/test_scripts_lelab.py cover the stop / teardown / port-check paths
with mocked psutil + subprocess (no real processes spawned).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant