arcade-mcp/libs
Eric Gustin 5602578b2f
Worker Stability (#688)
This PR does three things:
1. Executes synchronous tool calls in thread pool allowing for up to 4 +
# of CPUs executions in parallel.
2. Makes force quitting via double SIGINT/SIGTERM possible and via
single SIGINT/SIGTERM + graceful shutdown timeout expiry possible, even
if there are active connections.
3. Sets `timeout_graceful_shutdown` to
`ARCADE_UVICORN_TIMEOUT_GRACEFUL_SHUTDOWN` env var if set, else defaults
to 15.
4. Disable the worker health check span to reduce noise

Tradeoffs:
Since this PR introduces executing synchronous tools via `await
asyncio.to_thread(func, **func_args)`, this means that there is no way
for the thread to be killed until it finishes. The ramifications of this
is that the force quitting logic that is also implemented in this PR has
to be very harsh `os._exit(1)` just in case there is a sync tool
actively executing. This means that `MCPApp` teardown logic will not
execute when force quitting is required. Although this was already the
case because we weren't previously able to force quit! This tradeoff is
justified for now since "parallel" tool executions will relieve us of
many worker timeouts that we are seeing in prod.

Future work:
Minimize/eliminate the need for `os._exit(1)` such that `MCPApp`
teardown logic will always execute, even when force quitting. The
solution will likely be moving away from `await asyncio.to_thread(func,
**func_args)` (while maintaining "parallelism" and then utilize the
`TaskTrackerMiddleware` introduced in this PR to cancel all of the
active HTTP requests.

Resolves PLT-713
2025-11-20 11:13:41 -08:00
..
arcade-cli Do not require entrypoint for arcade configure for HTTP server (#684) 2025-11-12 10:21:44 -08:00
arcade-core Worker Stability (#688) 2025-11-20 11:13:41 -08:00
arcade-evals MCP Local (#563) 2025-09-25 15:28:15 -07:00
arcade-mcp-server Worker Stability (#688) 2025-11-20 11:13:41 -08:00
arcade-serve Worker Stability (#688) 2025-11-20 11:13:41 -08:00
arcade-tdk Fixing 403 error always being RateLimiting (#685) 2025-11-13 22:20:32 -03:00
tests Worker Stability (#688) 2025-11-20 11:13:41 -08:00