mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-15 00:07:28 +00:00
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:
@@ -311,8 +311,9 @@ async def stream_generate_chat_completion(
|
||||
except CancelledError:
|
||||
# Get out if the request gets disconnected
|
||||
|
||||
abort_event.set()
|
||||
handle_request_disconnect("Chat completion generation cancelled by user.")
|
||||
if not disconnect_task.done():
|
||||
abort_event.set()
|
||||
handle_request_disconnect("Chat completion generation cancelled by user.")
|
||||
except Exception:
|
||||
yield get_generator_error(
|
||||
"Chat completion aborted. Please check the server console."
|
||||
|
||||
@@ -162,10 +162,11 @@ async def stream_generate_completion(
|
||||
except CancelledError:
|
||||
# Get out if the request gets disconnected
|
||||
|
||||
abort_event.set()
|
||||
handle_request_disconnect(
|
||||
f"Completion generation {request.state.id} cancelled by user."
|
||||
)
|
||||
if not disconnect_task.done():
|
||||
abort_event.set()
|
||||
handle_request_disconnect(
|
||||
f"Completion generation {request.state.id} cancelled by user."
|
||||
)
|
||||
except Exception:
|
||||
yield get_generator_error(
|
||||
f"Completion {request.state.id} aborted. Please check the server console."
|
||||
|
||||
Reference in New Issue
Block a user