Skip to content

Commit f805aaa

Browse files
committed
Debug
1 parent 080cbc2 commit f805aaa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,15 +656,19 @@ async def connect(self, force=False):
656656
self._sending = asyncio.Queue()
657657
if self._exit_task:
658658
self._exit_task.cancel()
659+
logger.debug(f"self.state={self.state}")
659660
if self.state not in (State.OPEN, State.CONNECTING) or force:
660661
try:
661662
await asyncio.wait_for(self._cancel(), timeout=10.0)
662663
except asyncio.TimeoutError:
663664
logger.debug(f"Timed out waiting for cancellation")
664665
pass
665-
self.ws = await asyncio.wait_for(
666+
logger.debug("Attempting connection")
667+
connection = await asyncio.wait_for(
666668
connect(self.ws_url, **self._options), timeout=10.0
667669
)
670+
logger.debug("Connection established")
671+
self.ws = connection
668672
if self._send_recv_task is None or self._send_recv_task.done():
669673
self._send_recv_task = asyncio.get_running_loop().create_task(
670674
self._handler(self.ws)
@@ -700,6 +704,7 @@ async def _handler(self, ws: ClientConnection) -> Union[None, Exception]:
700704
for original_id, payload in list(self._inflight.items()):
701705
self._received[original_id] = loop.create_future()
702706
to_send = json.loads(payload)
707+
logger.debug(f"Resubmitting {to_send}")
703708
await self._sending.put(to_send)
704709
if is_retry:
705710
# Otherwise the connection was just closed due to no activity, which should not count against retries
@@ -710,6 +715,7 @@ async def _handler(self, ws: ClientConnection) -> Union[None, Exception]:
710715
)
711716
await self.connect(True)
712717
await self._handler(ws=self.ws)
718+
logger.debug(f"Current send queue size: {self._sending.qsize()}")
713719
return None
714720
elif isinstance(e := recv_task.result(), Exception):
715721
return e

0 commit comments

Comments
 (0)