(self, request_dict, operation_model)
| 188 | self._set_ttl(retries_context, read_timeout, success_response) |
| 189 | |
| 190 | def _send_request(self, request_dict, operation_model): |
| 191 | attempts = 1 |
| 192 | context = request_dict['context'] |
| 193 | self._update_retries_context(context, attempts) |
| 194 | request = self.create_request(request_dict, operation_model) |
| 195 | success_response, exception = self._get_response( |
| 196 | request, operation_model, context |
| 197 | ) |
| 198 | while self._needs_retry( |
| 199 | attempts, |
| 200 | operation_model, |
| 201 | request_dict, |
| 202 | success_response, |
| 203 | exception, |
| 204 | ): |
| 205 | attempts += 1 |
| 206 | self._update_retries_context(context, attempts, success_response) |
| 207 | # If there is a stream associated with the request, we need |
| 208 | # to reset it before attempting to send the request again. |
| 209 | # This will ensure that we resend the entire contents of the |
| 210 | # body. |
| 211 | request.reset_stream() |
| 212 | # Create a new request when retried (including a new signature). |
| 213 | request = self.create_request(request_dict, operation_model) |
| 214 | success_response, exception = self._get_response( |
| 215 | request, operation_model, context |
| 216 | ) |
| 217 | if ( |
| 218 | success_response is not None |
| 219 | and 'ResponseMetadata' in success_response[1] |
| 220 | ): |
| 221 | # We want to share num retries, not num attempts. |
| 222 | total_retries = attempts - 1 |
| 223 | success_response[1]['ResponseMetadata']['RetryAttempts'] = ( |
| 224 | total_retries |
| 225 | ) |
| 226 | if exception is not None: |
| 227 | raise exception |
| 228 | else: |
| 229 | return success_response |
| 230 | |
| 231 | def _get_response(self, request, operation_model, context): |
| 232 | # This will return a tuple of (success_response, exception) |
no test coverage detected