submarine_swaps: define main_loop, with async with taskgroup
rm unneeded @ignore_exception wrapper in lnworker and network
This commit is contained in:
@@ -309,7 +309,6 @@ class LNWorker(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
|
||||
except OSError as e:
|
||||
self.logger.error(f"cannot listen for lightning p2p. error: {e!r}")
|
||||
|
||||
@ignore_exceptions # don't kill outer taskgroup
|
||||
async def main_loop(self):
|
||||
self.logger.info("starting taskgroup.")
|
||||
try:
|
||||
|
||||
@@ -207,8 +207,17 @@ class SwapManager(Logger):
|
||||
self.add_lnwatcher_callback(swap)
|
||||
|
||||
self.taskgroup = OldTaskGroup()
|
||||
coro = self.pay_pending_invoices()
|
||||
asyncio.run_coroutine_threadsafe(self.taskgroup.spawn(coro), self.network.asyncio_loop)
|
||||
asyncio.run_coroutine_threadsafe(self.main_loop(), self.network.asyncio_loop)
|
||||
|
||||
async def main_loop(self):
|
||||
self.logger.info("starting taskgroup.")
|
||||
try:
|
||||
async with self.taskgroup as group:
|
||||
await group.spawn(self.pay_pending_invoices())
|
||||
except Exception as e:
|
||||
self.logger.exception("taskgroup died.")
|
||||
finally:
|
||||
self.logger.info("taskgroup stopped.")
|
||||
|
||||
async def pay_invoice(self, key):
|
||||
self.logger.info(f'trying to pay invoice {key}')
|
||||
|
||||
@@ -452,7 +452,6 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
def _init_lnworker(self):
|
||||
self.lnworker = None
|
||||
|
||||
@ignore_exceptions # don't kill outer taskgroup
|
||||
async def main_loop(self):
|
||||
self.logger.info("starting taskgroup.")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user