def _perform_request(self, request, parser=None, parser_args=None, operation_context=None):
operation_context = operation_context or _OperationContext()<EOL>retry_context = RetryContext()<EOL>self._apply_host(request, operation_context, retry_context)<EOL>_update_request(request, self._X_MS_VERSION, self._USER_AGENT_STRING)<EOL>client_request_id_prefix = str.format("<STR_LIT>", request.headers['<STR_LIT>'])<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>try:<EOL><INDENT>if self.request_callback:<EOL><INDENT>self.request_callback(request)<EOL><DEDENT>_add_date_header(request)<EOL>self.authentication.sign_request(request)<EOL>retry_context.request = request<EOL>logger.info("<STR_LIT>",<EOL>client_request_id_prefix,<EOL>request.method,<EOL>request.path,<EOL>request.query,<EOL>str(request.headers).replace('<STR_LIT:\n>', '<STR_LIT>'))<EOL>response = self._httpclient.perform_request(request)<EOL>if self.response_callback:<EOL><INDENT>self.response_callback(response)<EOL><DEDENT>retry_context.response = response<EOL>logger.info("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>client_request_id_prefix,<EOL>self.extract_date_and_request_id(retry_context),<EOL>response.status,<EOL>response.message,<EOL>str(request.headers).replace('<STR_LIT:\n>', '<STR_LIT>'))<EOL>if response.status >= <NUM_LIT>:<EOL><INDENT>_http_error_handler(<EOL>HTTPError(response.status, response.message, response.headers, response.body))<EOL><DEDENT>if parser:<EOL><INDENT>if parser_args:<EOL><INDENT>args = [response]<EOL>args.extend(parser_args)<EOL>return parser(*args)<EOL><DEDENT>else:<EOL><INDENT>return parser(response)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT><DEDENT>except AzureException as ex:<EOL><INDENT>retry_context.exception = ex<EOL>raise ex<EOL><DEDENT>except Exception as ex:<EOL><INDENT>retry_context.exception = ex<EOL>if sys.version_info >= (<NUM_LIT:3>,):<EOL><INDENT>raise AzureException(ex.args[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>msg = "<STR_LIT>"<EOL>if len(ex.args) > <NUM_LIT:0>:<EOL><INDENT>msg = ex.args[<NUM_LIT:0>]<EOL><DEDENT>raise AzureException('<STR_LIT>'.format(ex.__class__.__name__, msg))<EOL><DEDENT><DEDENT><DEDENT>except AzureException as ex:<EOL><INDENT>if logger.isEnabledFor(logging.CRITICAL):<EOL><INDENT>exception_str_in_one_line = str(ex).replace('<STR_LIT:\n>', '<STR_LIT>')<EOL>status_code = retry_context.response.status if retry_context.response is not None else '<STR_LIT>'<EOL>timestamp_and_request_id = self.extract_date_and_request_id(retry_context)<EOL><DEDENT>logger.info("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>client_request_id_prefix,<EOL>retry_context.count if hasattr(retry_context, '<STR_LIT:count>') else <NUM_LIT:0>,<EOL>timestamp_and_request_id,<EOL>status_code,<EOL>exception_str_in_one_line)<EOL>if str(ex) == _ERROR_DECRYPTION_FAILURE:<EOL><INDENT>logger.error("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>client_request_id_prefix,<EOL>timestamp_and_request_id,<EOL>status_code,<EOL>exception_str_in_one_line)<EOL>raise ex<EOL><DEDENT>retry_interval = self.retry(retry_context)<EOL>if retry_interval is not None:<EOL><INDENT>if self.retry_callback:<EOL><INDENT>self.retry_callback(retry_context)<EOL><DEDENT>logger.info(<EOL>"<STR_LIT>",<EOL>client_request_id_prefix,<EOL>retry_context.count,<EOL>retry_interval)<EOL>sleep(retry_interval)<EOL><DEDENT>else:<EOL><INDENT>logger.error("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>client_request_id_prefix,<EOL>timestamp_and_request_id,<EOL>status_code,<EOL>exception_str_in_one_line)<EOL>raise ex<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if operation_context.location_lock and not operation_context.host_location:<EOL><INDENT>operation_context.host_location = {retry_context.location_mode: request.host}<EOL><DEDENT><DEDENT><DEDENT>
Sends the request and return response. Catches HTTPError and hands it
to error handler