1
0

daemon/wallet/network: make stop() methods async

This commit is contained in:
SomberNight
2021-03-09 17:52:36 +01:00
parent ce88b36e81
commit 3c019c2f9c
15 changed files with 123 additions and 70 deletions

View File

@@ -311,11 +311,11 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
self._add_peers_from_config()
asyncio.run_coroutine_threadsafe(self.main_loop(), self.network.asyncio_loop)
def stop(self):
async def stop(self):
if self.listen_server:
self.network.asyncio_loop.call_soon_threadsafe(self.listen_server.close)
asyncio.run_coroutine_threadsafe(self.taskgroup.cancel_remaining(), self.network.asyncio_loop)
self.listen_server.close()
util.unregister_callback(self.on_proxy_changed)
await self.taskgroup.cancel_remaining()
def _add_peers_from_config(self):
peer_list = self.config.get('lightning_peers', [])
@@ -704,9 +704,9 @@ class LNWallet(LNWorker):
tg_coro = self.taskgroup.spawn(coro)
asyncio.run_coroutine_threadsafe(tg_coro, self.network.asyncio_loop)
def stop(self):
super().stop()
self.lnwatcher.stop()
async def stop(self):
await super().stop()
await self.lnwatcher.stop()
self.lnwatcher = None
def peer_closed(self, peer):