@@ -159,7 +159,12 @@ def is_retryable(error):
159159 print ('{0} {1}' .format (now , repr (error )))
160160
161161 def is_retryable_status_code (error ):
162- return isinstance (error , requests .HTTPError ) and not (400 <= error .response .status_code <= 499 )
162+ if not isinstance (error , requests .HTTPError ):
163+ return False
164+ if error .response .status_code == 409 :
165+ return True
166+ else :
167+ return not (400 <= error .response .status_code <= 499 )
163168
164169 return is_retryable_status_code (error ) or isinstance (error ,
165170 (requests .ConnectionError , requests .ReadTimeout ))
@@ -293,7 +298,7 @@ def _get_next_file_suffix(files):
293298
294299 @staticmethod
295300 def check_status (response ):
296- """Check that the response status code is in range 200-299.
301+ """Check that the response status code is in range 200-299, or 409 .
297302 Raises a ValueError and prints response_text if status is not in the expected range. Otherwise,
298303 just returns silently.
299304 Args:
@@ -311,7 +316,7 @@ def check_status(response):
311316 check_status(301, 'bar') raises error
312317 """
313318 status = response .status_code
314- matches = 200 <= status <= 299
319+ matches = 200 <= status <= 299 or status == 409
315320 if not matches :
316321 message = 'HTTP status code {0} is not in expected range 2xx. Response: {1}' .format (status , response .text )
317322 raise requests .HTTPError (message , response = response )
0 commit comments