fix: handle coroutine check for on_disconnect callback in chat API (#3930)

Handle coroutine check for on_disconnect callback in chat API
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-09-26 10:28:17 -03:00 committed by GitHub
commit 56d8b0fa49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -448,7 +448,9 @@ class DisconnectHandlerStreamingResponse(StreamingResponse):
message = await receive()
if message["type"] == "http.disconnect":
if self.on_disconnect:
await self.on_disconnect()
coro = self.on_disconnect()
if asyncio.iscoroutine(coro):
await coro
break