aboutsummaryrefslogtreecommitdiffstats
path: root/static-builds
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-08-17 00:05:33 +0100
committerGravatar Chris Lovering <[email protected]>2022-09-30 15:43:31 +0100
commit1d47dc4cc435131934883a0ccb2a359d2ac177d8 (patch)
treebd2e8f3ef13f2e285b150b64e6d1f354d5e2a234 /static-builds
parentMerge pull request #760 from python-discord/dependabot/pip/django-4.0.7 (diff)
Use a httpx.Client for netlify static builds
This allows for setting the config in one place and reusing it. This also solves an issue where the requests to fetch the download URL would timeout after the (default) 5 seconds.
Diffstat (limited to 'static-builds')
-rw-r--r--static-builds/netlify_build.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/static-builds/netlify_build.py b/static-builds/netlify_build.py
index f3a53f72..36520c28 100644
--- a/static-builds/netlify_build.py
+++ b/static-builds/netlify_build.py
@@ -28,6 +28,11 @@ def raise_response(response: httpx.Response) -> None:
if __name__ == "__main__":
+ client = httpx.Client(
+ follow_redirects=True,
+ timeout=3 * 60,
+ )
+
owner, repo = parse.urlparse(os.getenv("REPOSITORY_URL")).path.lstrip("/").split("/")[0:2]
download_url = "/".join([
@@ -40,19 +45,19 @@ if __name__ == "__main__":
os.getenv("ARTIFACT_NAME"),
])
print(f"Fetching download URL from {download_url}")
- response = httpx.get(download_url, follow_redirects=True)
+ response = client.get(download_url)
raise_response(response)
# The workflow is still pending, retry in a bit
while response.status_code == 202:
print(f"{response.json()['error']}. Retrying in 10 seconds.")
time.sleep(10)
- response = httpx.get(download_url, follow_redirects=True)
+ response = client.get(download_url)
raise_response(response)
url = response.json()["url"]
print(f"Downloading build from {url}")
- zipped_content = httpx.get(url, follow_redirects=True, timeout=3 * 60)
+ zipped_content = client.get(url)
zipped_content.raise_for_status()
zip_file = Path("temp.zip")