fix: replace sync httpx.get with async client in build-status + terminal (#17)

This commit is contained in:
chrischristiansen-glitch 2026-06-13 18:00:59 +02:00 committed by GitHub
parent 95ad4f799a
commit 1e6bc5b815
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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", ""),