Skip to content

Commit 224ac4f

Browse files
authored
Merge pull request #10 from polygon-io/dev
Add on_error on_close
2 parents c27baea + 3332c98 commit 224ac4f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

polygon/websocket/websocket_client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class WebSocketClient:
1616
# the 3 possible clusters (I think I like client per, but then a problem is the user can make multiple clients for
1717
# the same cluster and that's not desirable behavior,
1818
# somehow keeping track with multiple Client instances will be the difficulty)
19-
def __init__(self, cluster: str, auth_key: str, process_message: Optional[Callable[[str], None]] = None):
19+
def __init__(self, cluster: str, auth_key: str, process_message: Optional[Callable[[str], None]] = None,
20+
on_close: Optional[Callable[[str], None]] = None, on_error: Optional[Callable[[str], None]] = None):
2021
self._host = self.DEFAULT_HOST
2122
self.url = f"wss://{self._host}/{cluster}"
2223
self.ws: websocket.WebSocketApp = websocket.WebSocketApp(self.url, on_open=self._default_on_open(),
@@ -26,6 +27,8 @@ def __init__(self, cluster: str, auth_key: str, process_message: Optional[Callab
2627
self.auth_key = auth_key
2728

2829
self.process_message = process_message
30+
self.ws.on_close = on_close
31+
self.ws.on_error = on_error
2932

3033
# being authenticated is an event that must occur before any other action is sent to the server
3134
self._authenticated = threading.Event()

0 commit comments

Comments
 (0)