transports(fastapi): don't try to close socket
The websocket is passed from outside (in the transport constructor) so we should not be trying to close it. FastAPI does actually close it later. We didn't see any issue because these functions were not implemented properly. The value to check was `application_state` instead of `client_state`. But in any case, Pipecat should not be responsible for closing things passed from outside.
This commit is contained in:
@@ -70,16 +70,6 @@ class FastAPIWebsocketInputTransport(BaseInputTransport):
|
||||
await self._callbacks.on_client_connected(self._websocket)
|
||||
self._receive_task = self.get_event_loop().create_task(self._receive_messages())
|
||||
|
||||
async def stop(self, frame: EndFrame):
|
||||
await super().stop(frame)
|
||||
if self._websocket.client_state != WebSocketState.DISCONNECTED:
|
||||
await self._websocket.close()
|
||||
|
||||
async def cancel(self, frame: CancelFrame):
|
||||
await super().cancel(frame)
|
||||
if self._websocket.client_state != WebSocketState.DISCONNECTED:
|
||||
await self._websocket.close()
|
||||
|
||||
async def _receive_messages(self):
|
||||
async for message in self._websocket.iter_text():
|
||||
frame = self._params.serializer.deserialize(message)
|
||||
|
||||
Reference in New Issue
Block a user