-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add a configuration option to make callback logging synchronous #8202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
482180c
f356096
77de86e
0d9a3dd
5d8b359
a3fc795
53443a8
57f1d43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -788,9 +788,7 @@ async def _client_async_logging_helper( | |
f"Async Wrapper: Completed Call, calling async_success_handler: {logging_obj.async_success_handler}" | ||
) | ||
# check if user does not want this to be logged | ||
asyncio.create_task( | ||
logging_obj.async_success_handler(result, start_time, end_time) | ||
) | ||
await logging_obj.async_success_handler(result, start_time, end_time) | ||
logging_obj.handle_sync_success_callbacks_for_async_calls( | ||
result=result, | ||
start_time=start_time, | ||
|
@@ -1163,12 +1161,8 @@ def wrapper(*args, **kwargs): # noqa: PLR0915 | |
|
||
# LOG SUCCESS - handle streaming success logging in the _next_ object, remove `handle_success` once it's deprecated | ||
verbose_logger.info("Wrapper: Completed Call, calling success_handler") | ||
executor.submit( | ||
logging_obj.success_handler, | ||
result, | ||
start_time, | ||
end_time, | ||
) | ||
logging_obj.success_handler(result, start_time, end_time) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if moving to success_handler, make sure that uses an executor, so as to not cause high cpu consumption @B-Step62 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the catch, updated. |
||
|
||
# RETURN RESULT | ||
update_response_metadata( | ||
result=result, | ||
|
@@ -1336,15 +1330,18 @@ async def wrapper_async(*args, **kwargs): # noqa: PLR0915 | |
) | ||
|
||
# LOG SUCCESS - handle streaming success logging in the _next_ object | ||
asyncio.create_task( | ||
_client_async_logging_helper( | ||
logging_obj=logging_obj, | ||
result=result, | ||
start_time=start_time, | ||
end_time=end_time, | ||
is_completion_with_fallbacks=is_completion_with_fallbacks, | ||
) | ||
async_logging_params = dict( | ||
logging_obj=logging_obj, | ||
result=result, | ||
start_time=start_time, | ||
end_time=end_time, | ||
is_completion_with_fallbacks=is_completion_with_fallbacks, | ||
) | ||
if litellm.sync_logging: | ||
await _client_async_logging_helper(**async_logging_params) | ||
else: | ||
asyncio.create_task(_client_async_logging_helper(**async_logging_params)) | ||
|
||
logging_obj.handle_sync_success_callbacks_for_async_calls( | ||
result=result, | ||
start_time=start_time, | ||
|
Uh oh!
There was an error while loading. Please reload this page.