mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-10 04:22:35 +02:00
Spark: increase timeout and improved error handling (#718)
* increase timeout and more error handling * more error handling * add timeout exception
This commit is contained in:
@@ -48,9 +48,16 @@ class SparkWallet(Wallet):
|
|||||||
self.url + "/rpc",
|
self.url + "/rpc",
|
||||||
headers={"X-Access": self.token},
|
headers={"X-Access": self.token},
|
||||||
json={"method": key, "params": params},
|
json={"method": key, "params": params},
|
||||||
timeout=40,
|
timeout=60 * 60 * 24,
|
||||||
)
|
)
|
||||||
except (OSError, httpx.ConnectError, httpx.RequestError) as exc:
|
r.raise_for_status()
|
||||||
|
except (
|
||||||
|
OSError,
|
||||||
|
httpx.ConnectError,
|
||||||
|
httpx.RequestError,
|
||||||
|
httpx.HTTPError,
|
||||||
|
httpx.TimeoutException,
|
||||||
|
) as exc:
|
||||||
raise UnknownError("error connecting to spark: " + str(exc))
|
raise UnknownError("error connecting to spark: " + str(exc))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -203,7 +210,13 @@ class SparkWallet(Wallet):
|
|||||||
data = json.loads(line[5:])
|
data = json.loads(line[5:])
|
||||||
if "pay_index" in data and data.get("status") == "paid":
|
if "pay_index" in data and data.get("status") == "paid":
|
||||||
yield data["label"]
|
yield data["label"]
|
||||||
except (OSError, httpx.ReadError, httpx.ConnectError, httpx.ReadTimeout):
|
except (
|
||||||
|
OSError,
|
||||||
|
httpx.ReadError,
|
||||||
|
httpx.ConnectError,
|
||||||
|
httpx.ReadTimeout,
|
||||||
|
httpx.HTTPError,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.error("lost connection to spark /stream, retrying in 5 seconds")
|
logger.error("lost connection to spark /stream, retrying in 5 seconds")
|
||||||
|
Reference in New Issue
Block a user