fix: wire lifespan into FastMCP and remove asyncio.sleep placeholder#24
Open
mkostersitz wants to merge 1 commit into
Open
fix: wire lifespan into FastMCP and remove asyncio.sleep placeholder#24mkostersitz wants to merge 1 commit into
mkostersitz wants to merge 1 commit into
Conversation
Review Summary by QodoWire lifespan into FastMCP and remove sleep placeholder
WalkthroughsDescription• Wire lifespan hook into FastMCP constructor • Remove unused asyncio.sleep(1) placeholder • Drop now-unused asyncio import Diagramflowchart LR
A["lifespan function<br/>defined but unused"] -->|"wire via<br/>lifespan= kwarg"| B["FastMCP constructor<br/>receives lifespan"]
C["asyncio.sleep(1)<br/>placeholder"] -->|"remove"| D["Clean startup<br/>no delay"]
E["asyncio import<br/>unused"] -->|"drop"| F["Reduced imports"]
File Changes1. src/android_mcp/__main__.py
|
lifespan() was defined but never passed to FastMCP(), so it was dead code. Any future startup/shutdown logic added there would silently never run. Wire it in via the lifespan= kwarg. Also remove the asyncio.sleep(1) placeholder that served no purpose and drop the now-unused asyncio import. Co-Authored-By: Claude Sonnet 4.6 <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
lifespan()was defined but never passed toFastMCP():This meant
lifespanwas dead code — silently ignored on every startup. Any future initialization or shutdown logic added there would never run.Additionally, the body of
lifespancontainedawait asyncio.sleep(1)with a comment saying "Simulate startup latency" — a debugging artefact that added a 1-second delay to every server start for no reason.Fix
lifespan=lifespanto theFastMCPconstructorasyncio.sleep(1)placeholderasyncioimportNotes
The upstream code is already ahead of the version distributed via the Claude extension marketplace (which still had the original eager-connect crash). This is a small but real correctness fix — without it the lifespan hook is inert and can't be relied on for any future startup work (e.g. pre-warming the ADB connection, logging server info, etc.).
🤖 Generated with Claude Code