INNER CODE UNIT · Python
_t
tiliondev/fortress · mcp/server.py:186
async def _t() -> Tilion:
"""Return the shared Tilion instance, starting it on first use and REBUILDING
it if the browser has died (crash / dropped CDP). Concurrency-safe."""
global _tilion, _lock
if _lock is None: # bind lazily to the running loop (atomic: no await)
_lock = asyncio.Lock()
async with _lock:
if _tilion is not None and not _tilion.is_healthy():
try:
await _tilion.close()
except Exception:
pass
_tilion = None
if _tilion is None:
base_url = _env("BASE_URL")
api_key = _env("API_KEY")
headless = (_env("MCP_HEADLESS", "1") != "0")
# Egress + captcha come from env so an agent host can configure a residential