mirror of
https://github.com/lnbits/lnbits.git
synced 2025-11-23 12:29:25 +01:00
Wallets: Catch errors during cleanup (#1829)
* jetz aba * catch RuntimeError
This commit is contained in:
@@ -44,7 +44,10 @@ class EclairWallet(Wallet):
|
|||||||
self.client = httpx.AsyncClient(base_url=self.url, headers=self.auth)
|
self.client = httpx.AsyncClient(base_url=self.url, headers=self.auth)
|
||||||
|
|
||||||
async def cleanup(self):
|
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:
|
async def status(self) -> StatusResponse:
|
||||||
r = await self.client.post("/globalbalance", timeout=5)
|
r = await self.client.post("/globalbalance", timeout=5)
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ class LNbitsWallet(Wallet):
|
|||||||
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.key)
|
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.key)
|
||||||
|
|
||||||
async def cleanup(self):
|
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:
|
async def status(self) -> StatusResponse:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ class LndRestWallet(Wallet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def cleanup(self):
|
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:
|
async def status(self) -> StatusResponse:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ class LNPayWallet(Wallet):
|
|||||||
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
|
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
|
||||||
|
|
||||||
async def cleanup(self):
|
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:
|
async def status(self) -> StatusResponse:
|
||||||
url = f"/wallet/{self.wallet_key}"
|
url = f"/wallet/{self.wallet_key}"
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ class LnTipsWallet(Wallet):
|
|||||||
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
|
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
|
||||||
|
|
||||||
async def cleanup(self):
|
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:
|
async def status(self) -> StatusResponse:
|
||||||
r = await self.client.get("/api/v1/balance", timeout=40)
|
r = await self.client.get("/api/v1/balance", timeout=40)
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ class OpenNodeWallet(Wallet):
|
|||||||
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
|
self.client = httpx.AsyncClient(base_url=self.endpoint, headers=self.auth)
|
||||||
|
|
||||||
async def cleanup(self):
|
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:
|
async def status(self) -> StatusResponse:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ class SparkWallet(Wallet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def cleanup(self):
|
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):
|
def __getattr__(self, key):
|
||||||
async def call(*args, **kwargs):
|
async def call(*args, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user