fix rare edge cases on network

This commit is contained in:
Victor Shyba 2019-09-09 00:56:58 -03:00 committed by Lex Berezhny
parent 5dbc749000
commit 375c2a3363

View file

@ -177,8 +177,8 @@ class BaseNetwork:
try:
self._update_remote_height((await self.subscribe_headers(),))
log.info("Subscribed to headers: %s:%d", *self.client.server)
except asyncio.TimeoutError:
log.info("Switching to %s:%d timed out, closing and retrying.")
except (asyncio.TimeoutError, ConnectionError):
log.info("Switching to %s:%d timed out, closing and retrying.", *self.client.server)
self.client.synchronous_close()
self.client = None
@ -254,7 +254,8 @@ class BaseNetwork:
return await self.rpc('blockchain.address.subscribe', [address], True)
except asyncio.TimeoutError:
# abort and cancel, we cant lose a subscription, it will happen again on reconnect
self.client.abort()
if self.client:
self.client.abort()
raise asyncio.CancelledError()