lnpeer: Peer.is_initialized() should not raise

Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\main_window.py", line 434, in on_network_qt
    self.update_lightning_icon()
  File "...\electrum\electrum\gui\qt\main_window.py", line 2092, in update_lightning_icon
    cur, total = self.network.lngossip.get_sync_progress_estimate()
  File "...\electrum\electrum\lnworker.py", line 373, in get_sync_progress_estimate
    if self.num_peers() == 0:
  File "...\electrum\electrum\lnworker.py", line 202, in num_peers
    return sum([p.is_initialized() for p in self.peers.values()])
  File "...\electrum\electrum\lnworker.py", line 202, in
    return sum([p.is_initialized() for p in self.peers.values()])
  File "...\electrum\electrum\lnpeer.py", line 128, in is_initialized
    return self.initialized.done() and self.initialized.result() is True
concurrent.futures._base.CancelledError
This commit is contained in:
SomberNight 2020-02-29 20:10:02 +01:00
parent 67d24bf129
commit 0147623d11
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -124,8 +124,11 @@ class Peer(Logger):
if self._sent_init and self._received_init:
self.initialized.set_result(True)
def is_initialized(self):
return self.initialized.done() and self.initialized.result() is True
def is_initialized(self) -> bool:
return (self.initialized.done()
and not self.initialized.cancelled()
and self.initialized.exception() is None
and self.initialized.result() is True)
async def initialize(self):
if isinstance(self.transport, LNTransport):