Fix graceful shutdown for lightning swaps
This commit is contained in:
@@ -967,6 +967,8 @@ class LNWallet(LNWorker):
|
|||||||
if self.lnwatcher:
|
if self.lnwatcher:
|
||||||
await self.lnwatcher.stop()
|
await self.lnwatcher.stop()
|
||||||
self.lnwatcher = None
|
self.lnwatcher = None
|
||||||
|
if self.swap_manager: # may not be present in tests
|
||||||
|
await self.swap_manager.stop()
|
||||||
|
|
||||||
async def wait_for_received_pending_htlcs_to_get_removed(self):
|
async def wait_for_received_pending_htlcs_to_get_removed(self):
|
||||||
assert self.stopping_soon is True
|
assert self.stopping_soon is True
|
||||||
|
|||||||
@@ -219,6 +219,9 @@ class SwapManager(Logger):
|
|||||||
finally:
|
finally:
|
||||||
self.logger.info("taskgroup stopped.")
|
self.logger.info("taskgroup stopped.")
|
||||||
|
|
||||||
|
async def stop(self):
|
||||||
|
await self.taskgroup.cancel_remaining()
|
||||||
|
|
||||||
async def pay_invoice(self, key):
|
async def pay_invoice(self, key):
|
||||||
self.logger.info(f'trying to pay invoice {key}')
|
self.logger.info(f'trying to pay invoice {key}')
|
||||||
self.invoices_to_pay[key] = 1000000000000 # lock
|
self.invoices_to_pay[key] = 1000000000000 # lock
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
|
|||||||
self.network = MockNetwork(tx_queue, config=self.config)
|
self.network = MockNetwork(tx_queue, config=self.config)
|
||||||
self.taskgroup = OldTaskGroup()
|
self.taskgroup = OldTaskGroup()
|
||||||
self.lnwatcher = None
|
self.lnwatcher = None
|
||||||
|
self.swap_manager = None
|
||||||
self.listen_server = None
|
self.listen_server = None
|
||||||
self._channels = {chan.channel_id: chan for chan in chans}
|
self._channels = {chan.channel_id: chan for chan in chans}
|
||||||
self.payment_info = {}
|
self.payment_info = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user