Reliable shutdown on Windows + lelab --stop#46
Open
nobullryder wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 nextlelabthen 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.taskkill /Tfallback) so the uvicorn/Vite children and their handles are actually released.lelab --stopto free it") instead of an opaque bind error, plus a readiness wait before opening the browser.Tests
tests/test_scripts_lelab.pycovers the stop / teardown / port-check paths with mockedpsutil+subprocess(no real processes spawned).🤖 Generated with Claude Code