in alibabacloud_oss_v2/_client.py [0:0]
def _sent_http_request(self, context: SigningContext, options: _Options) -> HttpResponse:
request = context.request
retryer = options.retryer
max_attempts = self.retry_max_attempts(options)
# operation timeout
dealline = None
if isinstance(options.operation_timeout, (int, float)):
dealline = time.time() + options.operation_timeout
# Mark body
marked_body = _MarkedBody(request.body)
marked_body.mark()
reset_time = context.signing_time is None
error: Optional[Exception] = None
response: HttpResponse = None
for tries in range(max_attempts):
if tries > 0:
try:
marked_body.reset()
except: # pylint: disable=bare-except
# if meets reset error, just ignores, and retures last error
break
if reset_time:
context.signing_time = None
dealy = retryer.retry_delay(tries, error)
time.sleep(dealy)
# operation timeout
if dealline is not None and (time.time() > dealline):
break
try:
error = None
response = self._sent_http_request_once(context, options)
break
except Exception as e:
error = e
# operation timeout
if dealline is not None and (time.time() > dealline):
break
if marked_body.is_seekable() is False:
break
if not retryer.is_error_retryable(error):
break
if error is not None:
raise error
return response