(performance improvement - litellm sdk + proxy) - ensure litellm does not create unnecessary threads when running async functions (#7680)

* fix handle_sync_success_callbacks_for_async_calls

* fix handle_sync_success_callbacks_for_async_calls

* fix linting / testing errors

* use handle_sync_success_callbacks_for_async_calls

* add unit testing for logging fixes
This commit is contained in:
Ishaan Jaff 2025-01-10 17:57:22 -08:00 committed by GitHub
parent ebc66c1e1e
commit 7e2cf585f2
4 changed files with 264 additions and 25 deletions

View file

@ -608,10 +608,11 @@ async def _client_async_logging_helper(
asyncio.create_task(
logging_obj.async_success_handler(result, start_time, end_time)
)
threading.Thread(
target=logging_obj.success_handler,
args=(result, start_time, end_time),
).start()
logging_obj.handle_sync_success_callbacks_for_async_calls(
result=result,
start_time=start_time,
end_time=end_time,
)
def client(original_function): # noqa: PLR0915
@ -1153,11 +1154,10 @@ def client(original_function): # noqa: PLR0915
is_completion_with_fallbacks=is_completion_with_fallbacks,
)
)
executor.submit(
logging_obj.success_handler,
result,
start_time,
end_time,
logging_obj.handle_sync_success_callbacks_for_async_calls(
result=result,
start_time=start_time,
end_time=end_time,
)
# REBUILD EMBEDDING CACHING
if (