fixes stalling client reconnect issue

This commit is contained in:
Lex Berezhny 2021-03-03 12:06:38 -05:00
parent f6d0847453
commit 9815ddef1f

View file

@ -296,10 +296,13 @@ class Network:
log.info("maintaining connection to spv server %s", server_str) log.info("maintaining connection to spv server %s", server_str)
self._keepalive_task = asyncio.create_task(self.client.keepalive_loop()) self._keepalive_task = asyncio.create_task(self.client.keepalive_loop())
try: try:
await asyncio.wait( if not self._urgent_need_reconnect.is_set():
[self._keepalive_task, self._urgent_need_reconnect.wait()], await asyncio.wait(
return_when=asyncio.FIRST_COMPLETED [self._keepalive_task, self._urgent_need_reconnect.wait()],
) return_when=asyncio.FIRST_COMPLETED
)
else:
await self._keepalive_task
if self._urgent_need_reconnect.is_set(): if self._urgent_need_reconnect.is_set():
log.warning("urgent reconnect needed") log.warning("urgent reconnect needed")
self._urgent_need_reconnect.clear() self._urgent_need_reconnect.clear()