diff --git a/litellm/litellm_core_utils/llm_request_utils.py b/litellm/litellm_core_utils/llm_request_utils.py index f5f28822ca1..e303fa4e0b6 100644 --- a/litellm/litellm_core_utils/llm_request_utils.py +++ b/litellm/litellm_core_utils/llm_request_utils.py @@ -77,8 +77,8 @@ def get_proxy_server_request_headers(litellm_params: Optional[dict]) -> dict: if litellm_params is None: return {} - proxy_request_headers = ( - litellm_params.get("proxy_server_request", {}).get("headers", {}) or {} - ) + proxy_server_request = litellm_params.get("proxy_server_request") or {} + if not isinstance(proxy_server_request, dict): + return {} - return proxy_request_headers + return proxy_server_request.get("headers") or {} diff --git a/litellm/litellm_core_utils/logging_worker.py b/litellm/litellm_core_utils/logging_worker.py index 3db3700ee07..d1b125e7523 100644 --- a/litellm/litellm_core_utils/logging_worker.py +++ b/litellm/litellm_core_utils/logging_worker.py @@ -507,11 +507,13 @@ class LoggingWorker: except asyncio.QueueEmpty: break - # Run the coroutine synchronously in new loop - # Note: We run the coroutine directly, not via create_task, - # since we're in a new event loop context + # Run the coroutine synchronously in new loop with a per-task + # timeout so a single hung coroutine cannot block the entire + # flush past the outer time budget. try: - loop.run_until_complete(task["coroutine"]) + loop.run_until_complete( + asyncio.wait_for(task["coroutine"], timeout=2.0) + ) processed += 1 except Exception: # Silent failure to not break user's program diff --git a/tests/local_testing/test_amazing_vertex_completion.py b/tests/local_testing/test_amazing_vertex_completion.py index a7128e30e57..5cb1e2c78e8 100644 --- a/tests/local_testing/test_amazing_vertex_completion.py +++ b/tests/local_testing/test_amazing_vertex_completion.py @@ -3688,7 +3688,6 @@ def test_vertex_ai_llama_tool_calling(): def test_vertex_schema_test(): load_vertex_ai_credentials() - litellm._turn_on_debug() def tool_call(text: str | None) -> str: return text or "No text provided"