Wallets: Catch errors during cleanup (#1829)
* jetz aba * catch RuntimeError
This commit is contained in:
parent
befb288900
commit
2d4c9f349b
7 changed files with 28 additions and 7 deletions
|
|
@ -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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
try:
|
||||||
await self.client.aclose()
|
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):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue