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:
calle 2022-07-12 13:22:55 +02:00 committed by GitHub
parent 41dda6fd01
commit 357860d849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,9 +48,16 @@ class SparkWallet(Wallet):
self.url + "/rpc",
headers={"X-Access": self.token},
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))
try:
@ -203,7 +210,13 @@ class SparkWallet(Wallet):
data = json.loads(line[5:])
if "pay_index" in data and data.get("status") == "paid":
yield data["label"]
except (OSError, httpx.ReadError, httpx.ConnectError, httpx.ReadTimeout):
except (
OSError,
httpx.ReadError,
httpx.ConnectError,
httpx.ReadTimeout,
httpx.HTTPError,
):
pass
logger.error("lost connection to spark /stream, retrying in 5 seconds")