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
58 lines
1.5 KiB
TOML
58 lines
1.5 KiB
TOML
[project]
|
|
name = "arcade-serve"
|
|
version = "3.1.0"
|
|
description = "Arcade Serve - Serving infrastructure for Arcade tools and workers"
|
|
readme = "README.md"
|
|
license = {text = "MIT"}
|
|
authors = [
|
|
{name = "Arcade", email = "dev@arcade.dev"},
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 5 - Production/Stable",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3.13",
|
|
]
|
|
requires-python = ">=3.10"
|
|
dependencies = [
|
|
"arcade-core>=3.0.0,<4.0.0",
|
|
"fastapi>=0.115.3",
|
|
"uvicorn>=0.30.0",
|
|
"watchfiles>=1.0.5",
|
|
"sse-starlette>=2.0.0",
|
|
"opentelemetry-instrumentation-fastapi==0.49b2",
|
|
"opentelemetry-exporter-otlp-proto-http==1.28.2",
|
|
"opentelemetry-exporter-otlp-proto-common==1.28.2",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.1.2",
|
|
"pytest-cov>=4.0.0",
|
|
"mypy>=1.5.1",
|
|
"pre-commit>=3.4.0",
|
|
"pytest-asyncio>=0.23.7",
|
|
]
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["arcade_serve"]
|
|
|
|
[tool.mypy]
|
|
files = ["arcade_serve"]
|
|
python_version = "3.10"
|
|
disallow_untyped_defs = true
|
|
disallow_any_unimported = true
|
|
no_implicit_optional = true
|
|
check_untyped_defs = true
|
|
warn_return_any = true
|
|
warn_unused_ignores = true
|
|
show_error_codes = true
|
|
ignore_missing_imports = true
|