fix(celesta): add HTTP timeout so an unreachable laser engine cannot hang startup - #643
Open
Alpaca233 wants to merge 1 commit into
Open
fix(celesta): add HTTP timeout so an unreachable laser engine cannot hang startup#643Alpaca233 wants to merge 1 commit into
Alpaca233 wants to merge 1 commit into
Conversation
…cannot hang startup CELESTA() is constructed synchronously in Microscope.build_from_global_config, right after the camera opens. Its HTTP helper called urllib.request.urlopen() with no timeout, so when the Celesta was unplugged, powered off, or on a different subnet the first `GET IP` request blocked forever and the GUI never appeared. The last thing in the log was the Toupcam frame diagnostics. - lumencor_httpcommand() now takes timeout= (default 5 s) and passes it to urlopen(), bounding both TCP connect and the response read. - CELESTA accepts a timeout= kwarg and routes every command through one _command() helper so the timeout applies uniformly. - The connection-failure log reports the actual IP and timeout in use. Behavior when the Celesta is still unreachable: startup now fails with a logged "Failed to connect to Lumencor Laser" error instead of hanging. It does not yet let the GUI come up without the laser. Tests: tests/control/test_celesta.py covers the default timeout, an explicit timeout, a timed-out connect marking the device offline, and the configured timeout reaching every request made during init. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCmWuptseJKs9AfLrVLkRR
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed changes are covered by focused tests with no unresolved issues.
Pull request overview
Adds bounded HTTP timeouts to prevent an unreachable Celesta laser from hanging startup.
Changes:
- Applies configurable timeouts to all Celesta HTTP requests.
- Improves connection-failure logging.
- Adds timeout propagation and offline-state tests.
File summaries
| File | Description |
|---|---|
software/control/celesta.py |
Adds configurable HTTP timeouts and centralized command dispatch. |
software/tests/control/test_celesta.py |
Tests timeout behavior, propagation, and offline state. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 a Squid with a Lumencor Celesta (
USE_CELESTA_ETHERNET_CONTROL = True), startup hung after the Toupcam began streaming. The last lines in the console were the camera'sframe N (CONTINUOUS)diagnostics and nothing else ever appeared.Microscope.build_from_global_configconstructsCELESTA()right after the camera. That driver's HTTP helper calledurllib.request.urlopen()with no timeout, so when the Celesta is unplugged, powered off, or the PC's NIC is not on the192.168.201.xsubnet, the firstGET IPrequest blocks indefinitely and the GUI window never opens.Fix
control/celesta.py:lumencor_httpcommand()takes atimeout=argument (defaultDEFAULT_TIMEOUT_S = 5.0) and passes it tourlopen(), bounding both the TCP connect and the response read.CELESTAaccepts atimeout=kwarg and routes every command through a single_command()helper, so the timeout applies to all requests uniformly.No behavior change when the Celesta is reachable.
When it is not reachable, startup now fails after roughly 10 s with a clear
Failed to connect to Lumencor Laser at ip: 192.168.201.200error (the constructor's request times out, then the illumination controller's first request raises) instead of hanging. Letting the GUI come up with the laser offline is out of scope here and would be a follow-up.Tests
New
tests/control/test_celesta.py(4 tests,urlopenmonkeypatched, no network):urlopenlive == False)__init__🤖 Generated with Claude Code
https://claude.ai/code/session_01UCmWuptseJKs9AfLrVLkRR