예제 #1
0
 def handle_future(self,
                   bravado_fut: HttpFuture,
                   include_meta: bool = False):
     resp: BravadoResponse = bravado_fut.response()
     if include_meta:
         return resp.result, resp.metadata
     else:
         return resp.result
예제 #2
0
 def _execute(self, call: HttpFuture, silent=False, remainingRetries=0):
     if not silent:
         self.logger.info("executing %s %s" % (str(call.operation.http_method).upper(), call.operation.path_name))
     # TODO: handle exception
     result = call.response().result
     if 'result' in result.keys() and result['result'] is not None:
         return result['result']
     else:
         if remainingRetries > 0:
             self.logger.debug('retry after empty result for %s: %s' % (call.operation.operation_id, str(result)))
             return self._execute(call, silent, remainingRetries - 1)
         else:
             self.logger.error('got empty result for %s: %s' % (call.operation.operation_id, str(result)))
             return None
예제 #3
0
 def _execute(self, call: HttpFuture, silent=False, remainingRetries=0):
     # TODO: handle exception
     result = call.response().result
     if 'result' in result.keys() and result['result'] is not None:
         return result['result']
     else:
         if remainingRetries > 0:
             self.logger.debug('retry after empty result for %s: %s' % (call.operation.operation_id, str(result)))
             return self._execute(call, silent, remainingRetries - 1)
         else:
             if self.on_api_error is not None:
                 msg = "unkown error"
                 if 'ret_msg' in result.keys():
                     msg = result['ret_msg']
                 self.on_api_error("problem sending request: %s %s: %s" %
                                   (str(call.operation.http_method).upper(), call.operation.path_name, msg))
             self.logger.error('got empty result for %s, \nparams:%s\nresult: %s' % (call.operation.operation_id, call.future.request.params, str(result)))
             return None