Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocketsClientHandler: Fix no await for websocket.close #43

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
omer9564 marked this conversation as resolved.
Show resolved Hide resolved

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