Wallets: Catch errors during cleanup (#1829)

* jetz aba

* catch RuntimeError
This commit is contained in:
callebtc 2023-07-21 09:50:50 +02:00 committed by GitHub
parent befb288900
commit 2d4c9f349b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 7 deletions

View File

@ -44,7 +44,10 @@ class EclairWallet(Wallet):
self.client = httpx.AsyncClient(base_url=self.url, headers=self.auth)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
async def status(self) -> StatusResponse:
r = await self.client.post("/globalbalance", timeout=5)

View File

@ -32,7 +32,10 @@ class LNbitsWallet(Wallet):
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.key)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
async def status(self) -> StatusResponse:
try:

View File

@ -69,7 +69,10 @@ class LndRestWallet(Wallet):
)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
async def status(self) -> StatusResponse:
try:

View File

@ -35,7 +35,10 @@ class LNPayWallet(Wallet):
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
async def status(self) -> StatusResponse:
url = f"/wallet/{self.wallet_key}"

View File

@ -33,7 +33,10 @@ class LnTipsWallet(Wallet):
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
async def status(self) -> StatusResponse:
r = await self.client.get("/api/v1/balance", timeout=40)

View File

@ -37,7 +37,10 @@ class OpenNodeWallet(Wallet):
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
async def status(self) -> StatusResponse:
try:

View File

@ -37,7 +37,10 @@ class SparkWallet(Wallet):
)
async def cleanup(self):
await self.client.aclose()
try:
await self.client.aclose()
except RuntimeError as e:
logger.warning(f"Error closing wallet connection: {e}")
def __getattr__(self, key):
async def call(*args, **kwargs):