INNER CODE UNIT · Python
_lifespan
tiliondev/fortress · mcp/server.py:154
async def _lifespan(_server):
"""Pre-warm the stealth browser at server startup so the agent's FIRST tool
call is a ~150ms warm hit, not a ~2.2s cold launch. Disable with
TILION_MCP_PREWARM=0. Shuts the browser down cleanly on exit."""
if _env("MCP_PREWARM", "1") != "0":
try:
await _t()
except Exception:
pass # never let a pre-warm failure block the server
try:
yield
finally:
global _tilion
if _tilion is not None:
try:
await _tilion.close()
except Exception:
pass