arcade-mcp/libs/arcade-core
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_core Worker Stability (#688) 2025-11-20 11:13:41 -08:00
pyproject.toml Worker Stability (#688) 2025-11-20 11:13:41 -08:00
README.md PyPI release arcade-serve and arcade-tdk (#432) 2025-06-13 13:06:11 -07:00

Arcade Core

Core library for the Arcade platform providing foundational components and utilities.

Overview

Arcade Core provides the essential building blocks for the Arcade platform:

  • Tool Catalog & Toolkit Management: Core classes for managing and organizing tools
  • Configuration & Schema Handling: Configuration management and validation
  • Authentication & Authorization: Auth providers and security utilities
  • Error Handling: Comprehensive error types and handling
  • Telemetry & Observability: Monitoring and tracing capabilities
  • Utilities: Common helper functions and validators

Installation

pip install arcade-core

Usage

  1. Install an arcade toolkit
pip install arcade-math
  1. Load the toolkit
import arcade_math
from arcade_core import ToolCatalog, Toolkit

# Create a tool catalog
catalog = ToolCatalog()

# Load a toolkit
toolkit = Toolkit.from_module(arcade_math)

License

MIT License - see LICENSE file for details.