当前位置: 首页>>代码示例>>Python>>正文


Python apiproxy_errors.Error方法代码示例

本文整理汇总了Python中google.appengine.runtime.apiproxy_errors.Error方法的典型用法代码示例。如果您正苦于以下问题:Python apiproxy_errors.Error方法的具体用法?Python apiproxy_errors.Error怎么用?Python apiproxy_errors.Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.runtime.apiproxy_errors的用法示例。


在下文中一共展示了apiproxy_errors.Error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MakeSyncCall

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def MakeSyncCall(service, call, request, response, stubmap=None):
  """The APIProxy entry point for a synchronous API call.

  Args:
    service: string representing which service to call
    call: string representing which function to call
    request: protocol buffer for the request
    response: protocol buffer for the response
    stubmap: optional APIProxyStubMap instance, for dependency injection.

  Returns:
    Response protocol buffer or None. Some implementations may return
    a response protocol buffer instead of modifying 'response'.
    Caller must use returned value in such cases. If 'response' is modified
    then returns None.

  Raises:
    apiproxy_errors.Error or a subclass.
  """
  if stubmap is None:
    stubmap = apiproxy
  return stubmap.MakeSyncCall(service, call, request, response) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:24,代码来源:apiproxy_stub_map.py

示例2: SetError

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def SetError(self, error, method=None, error_rate=1):
    """Set an error condition that may be raised when calls made to stub.

    If a method is specified, the error will only apply to that call.
    The error rate is applied to the method specified or all calls if
    method is not set.

    Args:
      error: An instance of apiproxy_errors.Error or None for no error.
      method: A string representing the method that the error will affect.
      error_rate: a number from [0, 1] that sets the chance of the error,
        defaults to 1.
    """
    assert error is None or isinstance(error, apiproxy_errors.Error)
    if method and error:
      self.__error_dict[method] = error, error_rate
    else:
      self.__error_rate = error_rate
      self.__error = error 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:apiproxy_stub.py

示例3: __get_stats_hook

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def __get_stats_hook(self, rpc):
    try:
      rpc.check_success()
    except apiproxy_errors.Error:
      return None
    response = rpc.response
    if not response.has_stats():
      return {
          STAT_HITS: 0,
          STAT_MISSES: 0,
          STAT_BYTE_HITS: 0,
          STAT_ITEMS: 0,
          STAT_BYTES: 0,
          STAT_OLDEST_ITEM_AGES: 0,
      }

    stats = response.stats()
    return {
        STAT_HITS: stats.hits(),
        STAT_MISSES: stats.misses(),
        STAT_BYTE_HITS: stats.byte_hits(),
        STAT_ITEMS: stats.items(),
        STAT_BYTES: stats.bytes(),
        STAT_OLDEST_ITEM_AGES: stats.oldest_item_age(),
    } 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:27,代码来源:__init__.py

示例4: __delete_hook

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def __delete_hook(self, rpc):
    try:
      rpc.check_success()
    except apiproxy_errors.Error:
      return None
    result = []
    for status in rpc.response.delete_status_list():
      if status == MemcacheDeleteResponse.DELETED:
        result.append(DELETE_SUCCESSFUL)
      elif status == MemcacheDeleteResponse.NOT_FOUND:
        result.append(DELETE_ITEM_MISSING)
      else:



        return None
    return result 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:19,代码来源:__init__.py

示例5: __set_with_policy_hook

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def __set_with_policy_hook(self, rpc):
    try:
      rpc.check_success()
    except apiproxy_errors.Error:
      return None

    response = rpc.response
    server_keys, user_key = rpc.user_data
    assert response.set_status_size() == len(server_keys)
    status_dict = {}
    for server_key, status in zip(server_keys, response.set_status_list()):


      if status in (MemcacheSetResponse.DEADLINE_EXCEEDED,
                    MemcacheSetResponse.UNREACHABLE,
                    MemcacheSetResponse.OTHER_ERROR):
        status = MemcacheSetResponse.ERROR
      status_dict[user_key[server_key]] = status
    return status_dict 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:__init__.py

示例6: __offset_hook

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def __offset_hook(self, rpc):
    mapping = rpc.user_data
    try:
      rpc.check_success()
    except apiproxy_errors.Error:
      return dict((k, None) for k in mapping.iterkeys())

    response = rpc.response
    assert response.item_size() == len(mapping)

    result_dict = {}
    for key, resp_item in zip(mapping.iterkeys(), response.item_list()):
      if (resp_item.increment_status() == MemcacheIncrementResponse.OK and
          resp_item.has_new_value()):
        result_dict[key] = resp_item.new_value()
      else:
        result_dict[key] = None

    return result_dict 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:__init__.py

示例7: execute_jobs

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def execute_jobs(jobs, txn_sleep_time):
  """Executes all jobs one by one, sleeping between them.

  This gives the datastore some time to "land" transactions. It's not a
  guarantee, but just a best effort attempt to avoid contention. If it
  happens, refetch_config() will resume unfinished work on the next iteration.

  There should be no casual dependencies between jobs. Even through they will
  be executed sequentially, some may fail, and this does NOT stop processing
  of subsequent jobs.

  Args:
    txn_sleep_time: how long to sleep between jobs.

  Returns:
    True if all jobs succeeded, False if at least one failed.
  """
  success = True
  for idx, job in enumerate(jobs):
    if idx:
      time.sleep(txn_sleep_time)
    try:
      job()
    except (
          apiproxy_errors.Error,
          datastore_errors.Error,
          replication.ReplicationTriggerError) as exc:
      logging.error(
          'Failed, will try again later: %s - %s',
          exc.__class__.__name__, exc)
      success = False
  return success 
开发者ID:luci,项目名称:luci-py,代码行数:34,代码来源:config.py

示例8: __flush_all_hook

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def __flush_all_hook(self, rpc):
    try:
      rpc.check_success()
    except apiproxy_errors.Error:
      return False
    return True 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:8,代码来源:__init__.py

示例9: __incrdecr_hook

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def __incrdecr_hook(self, rpc):
    try:
      rpc.check_success()
    except apiproxy_errors.Error:
      return None

    response = rpc.response
    if response.has_new_value():
      return response.new_value()
    return None 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:12,代码来源:__init__.py

示例10: start

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import Error [as 别名]
def start(self):
    with threading.Lock():
      self._server_thread = threading.Thread(target=self._start_server)
      self._server_thread.start()
      self._server_thread.join()
      if not self._port:
        raise errors.GrpcPortError('Error assigning grpc api port!') 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:9,代码来源:api_server.py


注:本文中的google.appengine.runtime.apiproxy_errors.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。