[Fix] guard get_proxy_server_request_headers and bound atexit flush

- get_proxy_server_request_headers raised AttributeError when
  litellm_params["proxy_server_request"] was set to None (the default
  for SDK callers). Guard the helper so it returns {} for None or
  non-dict values.
- LoggingWorker._flush_on_exit now wraps each queued coroutine in
  asyncio.wait_for(..., timeout=2.0) so a single hung coroutine cannot
  block the atexit handler past the outer 5s budget.
- Drop _turn_on_debug() from test_vertex_schema_test to reduce noise on
  a network-dependent test.
This commit is contained in:
Yuneng Jiang 2026-04-24 18:43:13 -07:00
parent d21e90f683
commit caec9ed583
No known key found for this signature in database
3 changed files with 10 additions and 9 deletions

View file

@ -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 {}

View file

@ -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

View file

@ -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"