Skip to content

Commit

Permalink
Merge pull request #43 from permitio/rk/fix-no-await-for-websocket-close
Browse files Browse the repository at this point in the history
WebSocketsClientHandler: Fix no await for websocket.close
  • Loading branch information
roekatz authored Aug 29, 2024
2 parents 6995cfe + 81b76bd commit 9367357
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 9367357

Please sign in to comment.