Skip to content
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
9 changes: 9 additions & 0 deletions async_substrate_interface/async_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ async def _handler(self, ws: ClientConnection) -> Union[None, Exception]:
self._attempts += 1
is_retry = True
if should_reconnect is True:
if len(self._received_subscriptions) > 0:
return SubstrateRequestException(
f"Unable to reconnect because there are currently open subscriptions."
)
for original_id, payload in list(self._inflight.items()):
self._received[original_id] = loop.create_future()
to_send = json.loads(payload)
Expand All @@ -662,6 +666,11 @@ async def _handler(self, ws: ClientConnection) -> Union[None, Exception]:
return e
elif isinstance(e := send_task.result(), Exception):
return e
elif len(self._received_subscriptions) > 0:
return SubstrateRequestException(
f"Currently open subscriptions while disconnecting. "
f"Ensure these are unsubscribed from before closing in the future."
)
return None

async def __aexit__(self, exc_type, exc_val, exc_tb):
Expand Down
Loading