make httpx calls async when doing them from view functions.
this is important so lnbits can call itself without hanging forever. and these functions are already async so it should have been this way since ever.
This commit is contained in:
parent
c81e61e4fe
commit
9cb58833ad
1 changed files with 30 additions and 23 deletions
|
|
@ -74,8 +74,13 @@ async def api_payments_create_invoice():
|
|||
|
||||
lnurl_response: Union[None, bool, str] = None
|
||||
if g.data.get("lnurl_callback"):
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
r = httpx.get(g.data["lnurl_callback"], params={"pr": payment_request}, timeout=10)
|
||||
r = await client.get(
|
||||
g.data["lnurl_callback"],
|
||||
params={"pr": payment_request},
|
||||
timeout=10,
|
||||
)
|
||||
if r.is_error:
|
||||
lnurl_response = r.text
|
||||
else:
|
||||
|
|
@ -149,8 +154,9 @@ async def api_payments_create():
|
|||
async def api_payments_pay_lnurl():
|
||||
domain = urlparse(g.data["callback"]).netloc
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
r = httpx.get(
|
||||
r = await client.get(
|
||||
g.data["callback"],
|
||||
params={"amount": g.data["amount"], "comment": g.data["comment"]},
|
||||
timeout=40,
|
||||
|
|
@ -293,7 +299,8 @@ async def api_lnurlscan(code: str):
|
|||
if url.is_login:
|
||||
return jsonify({"domain": domain, "kind": "auth", "error": "unsupported"})
|
||||
|
||||
r = httpx.get(url.url)
|
||||
async with httpx.AsyncClient() as client:
|
||||
r = await client.get(url.url, timeout=40)
|
||||
if r.is_error:
|
||||
return jsonify({"domain": domain, "error": "failed to get parameters"})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue