Browse Source

request_force_close: add 1s delay before closing the tranport,

so that the remote task does not get cancelled.
patch-4
ThomasV 3 years ago
parent
commit
57583c05cf
  1. 9
      electrum/lnworker.py

9
electrum/lnworker.py

@ -2268,15 +2268,20 @@ class LNWallet(LNWorker):
peer_addr = LNPeerAddr(host, port, node_id)
transport = LNTransport(privkey, peer_addr, proxy=self.network.proxy)
peer = Peer(self, node_id, transport, is_channel_backup=True)
async def trigger_force_close_and_wait():
# wait before closing the transport, so that
# remote has time to process the message.
await peer.trigger_force_close(channel_id)
await asyncio.sleep(1)
peer.transport.close()
try:
async with OldTaskGroup(wait=any) as group:
await group.spawn(peer._message_loop())
await group.spawn(peer.trigger_force_close(channel_id))
await group.spawn(trigger_force_close_and_wait())
return
except Exception as e:
self.logger.info(f'failed to connect {host} {e}')
continue
# TODO close/cleanup the transport
else:
raise Exception('failed to connect')

Loading…
Cancel
Save