Skip to content

Commit c96e895

Browse files
authored
Merge pull request #767 from python-discord/extend-download-timeout
Use a httpx.Client for netlify static builds
2 parents 3a3b58b + 1d47dc4 commit c96e895

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

static-builds/netlify_build.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def raise_response(response: httpx.Response) -> None:
2828

2929

3030
if __name__ == "__main__":
31+
client = httpx.Client(
32+
follow_redirects=True,
33+
timeout=3 * 60,
34+
)
35+
3136
owner, repo = parse.urlparse(os.getenv("REPOSITORY_URL")).path.lstrip("/").split("/")[0:2]
3237

3338
download_url = "/".join([
@@ -40,19 +45,19 @@ def raise_response(response: httpx.Response) -> None:
4045
os.getenv("ARTIFACT_NAME"),
4146
])
4247
print(f"Fetching download URL from {download_url}")
43-
response = httpx.get(download_url, follow_redirects=True)
48+
response = client.get(download_url)
4449
raise_response(response)
4550

4651
# The workflow is still pending, retry in a bit
4752
while response.status_code == 202:
4853
print(f"{response.json()['error']}. Retrying in 10 seconds.")
4954
time.sleep(10)
50-
response = httpx.get(download_url, follow_redirects=True)
55+
response = client.get(download_url)
5156

5257
raise_response(response)
5358
url = response.json()["url"]
5459
print(f"Downloading build from {url}")
55-
zipped_content = httpx.get(url, follow_redirects=True, timeout=3 * 60)
60+
zipped_content = client.get(url)
5661
zipped_content.raise_for_status()
5762

5863
zip_file = Path("temp.zip")

0 commit comments

Comments
 (0)