From c9761749ecbcd0bb13feef5e8173537c73110974 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 22 Jun 2026 09:05:22 -0700 Subject: [PATCH] Studio: correct the anyio<4.14 pin rationale (mixed-install ImportError, not a 4.14 cancel-scope bug) (#6579) * Studio: correct the anyio<4.14 pin rationale (mixed-install ImportError) The pin comments said "anyio 4.14+ breaks cancel scope on Python 3.13", but a clean anyio 4.14.0 works on 3.13 (cancel scopes, Event, and the asyncio backend import all pass). The actual failure is a half-resolved install: anyio 4.14 added TaskHandle, imported by __init__.py and _backends/_asyncio from _core/_tasks. When a stale 4.13 _core/_tasks (no TaskHandle) sits under 4.14's importers, the import raises ImportError and 500s the server. Correct the rationale; the <4.14 pin still stands as the way to keep one consistent anyio version. * Clarify the anyio override comment (mixed-install ImportError, not a 4.14 cancel-scope bug) --- studio/backend/requirements/no-torch-runtime.txt | 2 +- studio/backend/requirements/single-env/constraints.txt | 7 +++++-- .../requirements/single-env/overrides-darwin-arm64.txt | 10 ++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/studio/backend/requirements/no-torch-runtime.txt b/studio/backend/requirements/no-torch-runtime.txt index b0157cfea0..a611c009fb 100644 --- a/studio/backend/requirements/no-torch-runtime.txt +++ b/studio/backend/requirements/no-torch-runtime.txt @@ -56,7 +56,7 @@ httpx httpcore certifi idna -anyio>=3.0,<4.14.0 # 4.14+ breaks cancel scope on Py3.13 (#6483) +anyio>=3.0,<4.14.0 # one consistent <4.14: 4.14's TaskHandle importers over a stale 4.13 _core/_tasks -> ImportError (#6483) sniffio h11 diff --git a/studio/backend/requirements/single-env/constraints.txt b/studio/backend/requirements/single-env/constraints.txt index aad4c38664..a916c6fc75 100644 --- a/studio/backend/requirements/single-env/constraints.txt +++ b/studio/backend/requirements/single-env/constraints.txt @@ -13,8 +13,11 @@ fastmcp>=3.0.2 mcp>=1.24,<2 websockets>=15.0.1 -# anyio 4.14+ breaks cancel scope on Python 3.13 (#6483). Global cap so later -# with-deps steps (studio.txt, data-designer-deps.txt) can't re-resolve it up. +# Keep anyio on one consistent <4.14 line. anyio 4.14 added TaskHandle (imported +# by __init__.py and the asyncio backend from _core/_tasks); a clean 4.14 is fine +# on 3.13. The real failure (#6483) is a half-resolved install: a stale 4.13 +# _core/_tasks (no TaskHandle) under 4.14's importers raises ImportError and 500s +# the server. Global cap so later with-deps steps can't re-resolve it up. anyio<4.14.0 pandas==2.3.3 diff --git a/studio/backend/requirements/single-env/overrides-darwin-arm64.txt b/studio/backend/requirements/single-env/overrides-darwin-arm64.txt index 8558cd5b6c..a0e73c7efc 100644 --- a/studio/backend/requirements/single-env/overrides-darwin-arm64.txt +++ b/studio/backend/requirements/single-env/overrides-darwin-arm64.txt @@ -4,8 +4,10 @@ # happens at runtime via the side-car venvs. transformers>=4.57.6 -# mlx-vlm / mlx-lm pull anyio>=4.14, which conflicts with the constraints.txt -# cap (anyio<4.14.0, #6483: 4.14+ breaks cancel scope on Python 3.13). A -c -# constraint loses that conflict on macOS-arm and 4.14.0 gets installed; an -# override wins it, so force anyio down here too. +# mlx-vlm / mlx-lm pull anyio>=4.14, which fights the constraints.txt cap +# (anyio<4.14.0). The -c constraint loses that fight on macOS-arm, leaving a +# half-resolved anyio (4.14 importers over a stale 4.13 _core/_tasks with no +# TaskHandle) that ImportErrors and 500s the server (#6483; clean 4.14 is fine, +# it is the mix that breaks). An override wins the fight, so force one +# consistent <4.14 here too. anyio<4.14.0