@@ -778,29 +778,38 @@ def install(
778
778
# Download appropriate dotnet install script
779
779
dotnetInstallScriptExtension = '.ps1' if platform == 'win32' else '.sh'
780
780
dotnetInstallScriptName = 'dotnet-install' + dotnetInstallScriptExtension
781
- url = 'https://dot.net/v1/'
781
+ url = 'https://dot.net/v1/'
782
782
dotnetInstallScriptUrl = url + dotnetInstallScriptName
783
783
784
784
dotnetInstallScriptPath = path .join (install_dir , dotnetInstallScriptName )
785
785
786
786
getLogger ().info ('Downloading %s' , dotnetInstallScriptUrl )
787
787
count = 0
788
- while count < 3 :
788
+ max_count = 10
789
+ while count < max_count :
789
790
try :
790
791
with urlopen (dotnetInstallScriptUrl , context = ssl ._create_unverified_context ()) as response :
791
792
if "html" in response .info ()['Content-Type' ]:
792
793
count = count + 1
793
- sleep (1 ) # sleep one second
794
+ sleep (count ** 2 )
794
795
continue
795
796
with open (dotnetInstallScriptPath , 'wb' ) as outfile :
796
797
outfile .write (response .read ())
797
798
break
798
- except Exception :
799
+ except URLError as error :
800
+ getLogger ().warning (f"Could not download dotnet-install script from { dotnetInstallScriptUrl } ; { Reason : {error .reason }} ; Attempt { count } " )
801
+ count = count + 1
802
+ sleep (count ** 2 )
803
+ continue
804
+ except Exception as error :
805
+ getLogger ().warning (f"Could not download dotnet-install script from { dotnetInstallScriptUrl } ; { type (error ).__name__ } ; Attempt { count } " )
799
806
count = count + 1
800
- sleep (1 )
807
+ sleep (count ** 2 )
801
808
continue
802
809
803
- if count == 3 :
810
+ getLogger ().info (f"Downloaded { dotnetInstallScriptUrl } OK" )
811
+
812
+ if count == max_count :
804
813
getLogger ().error ("Fatal error: could not download dotnet-install script" )
805
814
raise Exception ("Fatal error: could not download dotnet-install script" )
806
815
0 commit comments