summaryrefslogtreecommitdiffstats
path: root/PCbuild
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-09-20 14:58:29 (GMT)
committerGitHub <noreply@github.com>2021-09-20 14:58:29 (GMT)
commitee41d01326ddf48c411c019a4e63343668ebd829 (patch)
treed8b8cfb2ab205b07a8ff59f3262a8239dfc85759 /PCbuild
parent3d16fc90ce36acaa846ee88bdd124f84d49395b3 (diff)
downloadcpython-ee41d01326ddf48c411c019a4e63343668ebd829.zip
cpython-ee41d01326ddf48c411c019a4e63343668ebd829.tar.gz
cpython-ee41d01326ddf48c411c019a4e63343668ebd829.tar.bz2
bpo-45055: Add retry when downloading externals on Windows (GH-28399)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl> (cherry picked from commit ef9e22b253253615098d22cb49141a2a1024ee3c) Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'PCbuild')
-rwxr-xr-xPCbuild/get_external.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/PCbuild/get_external.py b/PCbuild/get_external.py
index a682d38..4ecc892 100755
--- a/PCbuild/get_external.py
+++ b/PCbuild/get_external.py
@@ -3,6 +3,8 @@
import argparse
import os
import pathlib
+import sys
+import time
import zipfile
from urllib.request import urlretrieve
@@ -53,7 +55,22 @@ def main():
verbose=args.verbose,
)
final_name = args.externals_dir / args.tag
- extract_zip(args.externals_dir, zip_path).replace(final_name)
+ extracted = extract_zip(args.externals_dir, zip_path)
+ for wait in [1, 2, 3, 5, 8, 0]:
+ try:
+ extracted.replace(final_name)
+ break
+ except PermissionError as ex:
+ retry = f" Retrying in {wait}s..." if wait else ""
+ print(f"Encountered permission error '{ex}'.{retry}", file=sys.stderr)
+ time.sleep(wait)
+ else:
+ print(
+ f"ERROR: Failed to extract {final_name}.",
+ "You may need to restart your build",
+ file=sys.stderr,
+ )
+ sys.exit(1)
if __name__ == '__main__':