From c3f5dd780e171adeb8460f82dd3ce0a599af8351 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Mon, 19 Sep 2022 08:44:13 -0500 Subject: [PATCH] Revise exception handling. --- lbry/wallet/usage_payment.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lbry/wallet/usage_payment.py b/lbry/wallet/usage_payment.py index 44c4b14d5..54bac7595 100644 --- a/lbry/wallet/usage_payment.py +++ b/lbry/wallet/usage_payment.py @@ -37,8 +37,10 @@ class WalletServerPayer: delay = max(self.payment_period / 24, 10) log.warning("Payement failed. Will retry after %g seconds.", delay) asyncio.sleep(delay) - except Exception: - log.exception("Unexpected exception. Payment task exiting early.") + except BaseException as e: + if not isinstance(e, asyncio.CancelledError): + log.exception("Unexpected exception. Payment task exiting early.") + self.running = False raise async def _pay(self): @@ -78,8 +80,8 @@ class WalletServerPayer: self.wallet.get_accounts_or_all(None), self.wallet.get_account_or_default(None) ) - except InsufficientFundsError as e: - self._on_payment_controller.add_error(e) + except InsufficientFundsError: + self._on_payment_controller.add_error(InsufficientFundsError()) continue await self.ledger.broadcast_or_release(tx, blocking=True)