mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	gh-134262: Fix off by one errors in download retry functions (GH-134867)
This commit is contained in:
		
							parent
							
								
									e9d845b41d
								
							
						
					
					
						commit
						e64395e8eb
					
				
					 2 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -12,7 +12,7 @@
 | 
				
			||||||
def retrieve_with_retries(download_location, output_path, reporthook,
 | 
					def retrieve_with_retries(download_location, output_path, reporthook,
 | 
				
			||||||
                          max_retries=7):
 | 
					                          max_retries=7):
 | 
				
			||||||
    """Download a file with exponential backoff retry and save to disk."""
 | 
					    """Download a file with exponential backoff retry and save to disk."""
 | 
				
			||||||
    for attempt in range(max_retries):
 | 
					    for attempt in range(max_retries + 1):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            resp = urlretrieve(
 | 
					            resp = urlretrieve(
 | 
				
			||||||
                download_location,
 | 
					                download_location,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -169,7 +169,7 @@ def download_with_retries(download_location: str,
 | 
				
			||||||
                          base_delay: float = 2.25,
 | 
					                          base_delay: float = 2.25,
 | 
				
			||||||
                          max_jitter: float = 1.0) -> typing.Any:
 | 
					                          max_jitter: float = 1.0) -> typing.Any:
 | 
				
			||||||
    """Download a file with exponential backoff retry."""
 | 
					    """Download a file with exponential backoff retry."""
 | 
				
			||||||
    for attempt in range(max_retries):
 | 
					    for attempt in range(max_retries + 1):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            resp = urllib.request.urlopen(download_location)
 | 
					            resp = urllib.request.urlopen(download_location)
 | 
				
			||||||
        except urllib.error.URLError as ex:
 | 
					        except urllib.error.URLError as ex:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue