OAI: Remove double logging if request is cancelled

Uvicorn can log in both the request disconnect handler and the
CancelledError. However, these sometimes don't work and both
need to be checked. But, don't log twice if one works.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2024-07-22 21:48:59 -04:00
parent 14dfaf600a
commit d1706fb067
2 changed files with 8 additions and 6 deletions

View File

@@ -311,6 +311,7 @@ async def stream_generate_chat_completion(
except CancelledError:
# Get out if the request gets disconnected
if not disconnect_task.done():
abort_event.set()
handle_request_disconnect("Chat completion generation cancelled by user.")
except Exception:

View File

@@ -162,6 +162,7 @@ async def stream_generate_completion(
except CancelledError:
# Get out if the request gets disconnected
if not disconnect_task.done():
abort_event.set()
handle_request_disconnect(
f"Completion generation {request.state.id} cancelled by user."