mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* test(router): streamed Responses API requests are freed without a gc pass Covers a Responses stream read to the end, one that fell back mid-stream and one the caller closed mid-stream at the Router, and a streamed /v1/responses call through the proxy read to the end or dropped by the client (#51936). Streamed chat completions through the proxy stay covered as a guard. * fix(router): free streamed Responses API requests without waiting for a full gc The Responses stream wrapper was a class defined per call, so the class and its closures over the attempt sat in a reference cycle, and the fallback generator held the wrapper strongly. A finished or dropped stream kept its request, logging object and provider iterator alive until a gen-2 gc. Move FallbackResponsesStreamWrapper to module level, let the generator and recovery helpers reach it only through a weakref, and stop binding the caught mid-stream error to a generator frame local, whose traceback pinned that frame after a fallback or same-group retry. Fixes #51936 * test(router): name the freed-stream cases by how they end and rerun-proof the held-open gate Derive the parametrized endings from their Literal, drop a guard that repeated an existing fallback ordering test, reset the integration upstream gate per run, and keep the terminal event tuple private. * style(router): keep the existing complexity suppression on the Responses stream wrapper builder * test(router): drop the section heading comment from the freed-stream tests * fix(router): drop a finished Responses stream's failure explainer so the fallback walk can be freed The explainer added for cross-group fallback errors closes over the walk, and the walk keeps the last fallback stream, so a stream that fell back mid-way stayed alive until a full gc. Release it once the stream ends, after every place that reads it. |
||
|---|---|---|
| .. | ||
| core | ||
| __init__.py | ||
| test_enforce_model_rate_limits.py | ||
| test_io_token_rate_limits.py | ||
| test_router.py | ||
| test_router_callback_hook_sequence.py | ||
| test_router_endpoints.py | ||
| test_router_entry_points.py | ||
| test_router_facade.py | ||
| test_router_fallbacks.py | ||
| test_router_fuzz_regressions_rust_only.py | ||
| test_router_get_deployments.py | ||
| test_router_helper_utils.py | ||
| test_router_host.py | ||
| test_router_max_parallel_requests.py | ||
| test_router_provider_endpoints.py | ||
| test_router_retries.py | ||
| test_router_surface_check.py | ||
| test_router_timeout.py | ||
| test_router_vector_store_endpoints.py | ||