Skip to content

Commit 036501b

Browse files
authored
Fixed exceptions in QueryNodeStatus
QueryNodeStatus didn't take into account RemoteDisconnect exception, and was missing a generic exception catcher for web urllib reading.
1 parent dcddc90 commit 036501b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sentinel_sdk/modules/node.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import threading
33
import urllib.parse
44
import urllib.request
5+
import http.client
56
from typing import Any
67
import json
78
import uuid
@@ -73,7 +74,10 @@ def QueryNodeStatus(self, node: node_pb2.Node, is_in_thread: bool = False) -> st
7374
contents = '{"success":false,"urllib-error":"URLError encountered"}'
7475
except TimeoutError:
7576
contents = '{"success":false,"urllib-error":"Data reading timed out"}'
76-
77+
except http.client.RemoteDisconnected:
78+
contents = '{"success":false,"http-error":"Remote endpoint closed connection"}'
79+
except:
80+
contents = '{"success":false,"error":"Unrecognizable error encountered"}'
7781
if is_in_thread:
7882
self.__nodes_status_cache[node.address] = contents
7983
else:
@@ -198,4 +202,4 @@ def PostSession(
198202
return self.__post_session(
199203
f"{remote_url}/accounts/{self._account.address}/sessions/{session_id}",
200204
payload,
201-
)
205+
)

0 commit comments

Comments
 (0)