Skip to content

Commit

Permalink
WebSocketsClientHandler: Fix no await for websocket.close
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Aug 29, 2024
1 parent 6995cfe commit 81b76bd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastapi_websocket_rpc/websocket_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Websocket-client optional module not installed.
pass

class ProxyEnabledWebSocketClientHandler (SimpleWebSocket):
class ProxyEnabledWebSocketClientHandler(SimpleWebSocket):
"""
Handler that use https://websocket-client.readthedocs.io/en/latest module.
This implementation supports HTTP proxy, though HTTP_PROXY and HTTPS_PROXY environment variable.
Expand Down Expand Up @@ -93,7 +93,7 @@ async def recv(self):
async def close(self, code: int = 1000):
if self._websocket is not None:
# Case opened, we have something to close.
self._websocket.close(code)
await asyncio.get_event_loop().run_in_executor(None, self._websocket.close, code)

class WebSocketsClientHandler(SimpleWebSocket):
"""
Expand Down Expand Up @@ -154,7 +154,7 @@ async def recv(self):
async def close(self, code: int = 1000):
if self._websocket is not None:
# Case opened, we have something to close.
self._websocket.close(code)
await self._websocket.close(code)

def isNotInvalidStatusCode(value):
return not isinstance(value, InvalidStatusCode)
Expand Down

0 comments on commit 81b76bd

Please sign in to comment.