fix: replace sync httpx.get with async client in build-status + terminal (#17)
This commit is contained in:
parent
95ad4f799a
commit
1e6bc5b815
4
main.py
4
main.py
|
|
@ -185,7 +185,7 @@ async def build_status():
|
|||
creds, project = google.auth.default()
|
||||
creds.refresh(google.auth.transport.requests.Request())
|
||||
url = f"https://cloudbuild.googleapis.com/v1/projects/{project}/builds?pageSize=5"
|
||||
r = httpx.get(url, headers={"Authorization": f"Bearer {creds.token}"})
|
||||
async with httpx.AsyncClient(timeout=15.0) as client: r = await client.get(url, headers={"Authorization": f"Bearer {creds.token}"}) r.raise_for_status()
|
||||
builds = r.json().get("builds", [])
|
||||
return {"builds": [{"id": b["id"], "status": b["status"],
|
||||
"branch": b.get("substitutions", {}).get("BRANCH_NAME", ""),
|
||||
|
|
@ -245,7 +245,7 @@ async def terminal_exec(req: TerminalExecRequest):
|
|||
creds, project = google.auth.default()
|
||||
creds.refresh(google.auth.transport.requests.Request())
|
||||
url = f"https://cloudbuild.googleapis.com/v1/projects/{project}/builds?pageSize=5"
|
||||
r = httpx.get(url, headers={"Authorization": f"Bearer {creds.token}"}, timeout=10)
|
||||
async with httpx.AsyncClient(timeout=15.0) as client: r = await client.get(url, headers={"Authorization": f"Bearer {creds.token}"}) r.raise_for_status()
|
||||
builds = r.json().get("builds", [])
|
||||
result = [{"id": b["id"], "status": b["status"],
|
||||
"branch": b.get("substitutions", {}).get("BRANCH_NAME", ""),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user