mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(proxy): hold the logging object weakly in the detached stream failure hook The closure armed by _arm_detached_stream_failure_hook is stored on the logging object and captured the logging object, the request data that contains it, and the processing object that holds that data. Every streamed /v1/messages request therefore ended in a reference cycle and stayed in memory until a full cyclic GC pass instead of being freed by reference counting when the stream finished. Capture the logging object through a weakref, a copy of the request data without the litellm_logging_obj key, and the route type as a value. The hook adds the live logging object back to the request data when it fires. All three callers reach the hook through the logging object, so it is always alive at that point. Add a regression test that streams a request to completion, drops every reference, and checks with the cyclic collector disabled that the logging object is gone. Fixes #51277 * test(proxy): cover finished streamed /v1/messages calls being freed without a gc pass Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(proxy): annotate the finished-stream gc test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(proxy): split the freed-calls assert message under the line limit Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| chat_bridge | ||
| providers | ||
| responses_bridge | ||
| safeguards | ||
| test_anthropic_messages_caller_tools_wire.py | ||
| test_beta_gated_fields_wire.py | ||
| test_finished_requests_freed_wire.py | ||
| test_guardrail_block_stream.py | ||
| test_guardrail_long_tool_names_wire.py | ||
| test_message_threads_wire.py | ||
| test_messages_additional_drop_params_wire.py | ||
| test_tool_result_text_wire.py | ||