Skip to content

Commit 19ddcc7

Browse files
committed
sync
1 parent e63ee25 commit 19ddcc7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

async_substrate_interface/sync_substrate.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ def name(self):
632632
def connect(self, init=False):
633633
if init is True:
634634
try:
635+
logger.debug(f"Websocket connecting to {self.chain_endpoint}")
635636
return connect(self.chain_endpoint, max_size=self.ws_max_size)
636637
except (ConnectionError, socket.gaierror) as e:
637638
raise ConnectionError(e)
@@ -640,6 +641,7 @@ def connect(self, init=False):
640641
return self.ws
641642
else:
642643
try:
644+
logger.debug(f"Websocket reconnecting to {self.chain_endpoint}")
643645
self.ws = connect(self.chain_endpoint, max_size=self.ws_max_size)
644646
return self.ws
645647
except (ConnectionError, socket.gaierror) as e:
@@ -1902,6 +1904,7 @@ def _make_rpc_request(
19021904
raw_websocket_logger.debug(f"WEBSOCKET_SEND> {to_send}")
19031905
ws.send(json.dumps(to_send))
19041906
request_manager.add_request(item_id, payload["id"])
1907+
logger.debug(f"Submitted payload ID {payload['id']} with websocket ID {item_id}: {payload}")
19051908

19061909
while True:
19071910
try:
@@ -1948,6 +1951,10 @@ def _make_rpc_request(
19481951
subscription_added = True
19491952
except KeyError:
19501953
raise SubstrateRequestException(str(response))
1954+
logger.error(
1955+
f"Error received from subtensor for {item_id}: {response}\n"
1956+
f"Currently received responses: {request_manager.get_results()}"
1957+
)
19511958
decoded_response, complete = self._process_response(
19521959
response,
19531960
item_id,
@@ -1959,6 +1966,15 @@ def _make_rpc_request(
19591966
request_manager.add_response(
19601967
item_id, decoded_response, complete
19611968
)
1969+
if len(stringified_response := str(decoded_response)) < 2_000:
1970+
output_response = stringified_response
1971+
# avoids clogging logs up needlessly (esp for Metadata stuff)
1972+
else:
1973+
output_response = f"{stringified_response[:2_000]} (truncated)"
1974+
logger.debug(
1975+
f"Received response for item ID {item_id}:\n{output_response}\n"
1976+
f"Complete: {complete}"
1977+
)
19621978

19631979
if request_manager.is_complete:
19641980
break

0 commit comments

Comments
 (0)