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


Python apiproxy_errors.OverQuotaError方法代码示例

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


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

示例1: add_docs_to_index

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import OverQuotaError [as 别名]
def add_docs_to_index(cls, documents):
    """Adds a list of documents to a particular index.

    Args:
      documents: a list of search.Documents to add to the class' index.
    """
    index = cls.get_index()
    for doc in documents:
      try:
        index.put(doc)
      except search.PutError as err:
        result = err.results[0]
        if result.code == search.OperationResult.TRANSIENT_ERROR:
          index.put(doc)
      except (search.Error, apiproxy_errors.OverQuotaError):
        logging.error(_PUT_DOC_ERR_MSG, doc, index) 
开发者ID:google,项目名称:loaner,代码行数:18,代码来源:base_model.py

示例2: get_result

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import OverQuotaError [as 别名]
def get_result(self):
    try:
      return super(_PutOperationFuture, self).get_result()
    except apiproxy_errors.OverQuotaError, e:
      message = e.message + '; index = ' + self._index.name
      if self._index.namespace:
        message = message + ' in namespace ' + self._index.namespace
      raise apiproxy_errors.OverQuotaError(message) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:10,代码来源:search.py

示例3: PerformWork

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import OverQuotaError [as 别名]
def PerformWork(self, thread_pool):
    """Perform the work of this work item and report the results.

    Args:
      thread_pool: An AdaptiveThreadPool instance.

    Returns:
      A tuple (status, instruction) of the work status and an instruction
      for the ThreadGate.
    """
    status = adaptive_thread_pool.WorkItem.FAILURE
    instruction = adaptive_thread_pool.ThreadGate.DECREASE


    try:
      self.MarkAsTransferring()



      try:
        transfer_time = self._TransferItem(thread_pool)
        if transfer_time is None:
          status = adaptive_thread_pool.WorkItem.RETRY
          instruction = adaptive_thread_pool.ThreadGate.HOLD
        else:
          logger.debug('[%s] %s Transferred %d entities in %0.1f seconds',
                       threading.currentThread().getName(), self, self.count,
                       transfer_time)
          sys.stdout.write('.')
          sys.stdout.flush()
          status = adaptive_thread_pool.WorkItem.SUCCESS
          if transfer_time <= MAXIMUM_INCREASE_DURATION:
            instruction = adaptive_thread_pool.ThreadGate.INCREASE
          elif transfer_time <= MAXIMUM_HOLD_DURATION:
            instruction = adaptive_thread_pool.ThreadGate.HOLD
      except (db.InternalError, db.NotSavedError, db.Timeout,
              db.TransactionFailedError,
              apiproxy_errors.OverQuotaError,
              apiproxy_errors.DeadlineExceededError,
              apiproxy_errors.ApplicationError), e:

        status = adaptive_thread_pool.WorkItem.RETRY
        logger.exception('Retrying on non-fatal datastore error: %s', e)
      except urllib2.HTTPError, e:
        http_status = e.code
        if http_status >= 500 and http_status < 600:

          status = adaptive_thread_pool.WorkItem.RETRY
          logger.exception('Retrying on non-fatal HTTP error: %d %s',
                           http_status, e.msg)
        else:
          self.SetError()
          status = adaptive_thread_pool.WorkItem.FAILURE 
开发者ID:elsigh,项目名称:browserscope,代码行数:55,代码来源:bulkloader.py

示例4: _MakeCallDone

# 需要导入模块: from google.appengine.runtime import apiproxy_errors [as 别名]
# 或者: from google.appengine.runtime.apiproxy_errors import OverQuotaError [as 别名]
def _MakeCallDone(self):
    self._state = RPC.FINISHING
    self.cpu_usage_mcycles = self._result_dict['cpu_usage_mcycles']
    if self._result_dict['error'] == APPLICATION_ERROR:
      appl_err = self._result_dict['application_error']
      if appl_err == MEMCACHE_UNAVAILABLE and self.package == 'memcache':


        self._exception = apiproxy_errors.CapabilityDisabledError(
            'The memcache service is temporarily unavailable. %s'
            % self._result_dict['error_detail'])
      else:

        self._exception = apiproxy_errors.ApplicationError(
            appl_err,
            self._result_dict['error_detail'])
    elif self._result_dict['error'] == CAPABILITY_DISABLED:

      if self._result_dict['error_detail']:
        self._exception = apiproxy_errors.CapabilityDisabledError(
            self._result_dict['error_detail'])
      else:
        self._exception = apiproxy_errors.CapabilityDisabledError(
            "The API call %s.%s() is temporarily unavailable." % (
            self.package, self.call))
    elif self._result_dict['error'] == FEATURE_DISABLED:
      self._exception = apiproxy_errors.FeatureNotEnabledError(
            self._result_dict['error_detail'])
    elif self._result_dict['error'] == OVER_QUOTA:
      if self._result_dict['error_detail']:

        self._exception = apiproxy_errors.OverQuotaError(
            ('The API call %s.%s() required more quota than is available. %s' %
             (self.package, self.call, self._result_dict['error_detail'])))
      else:

        exception_entry = _ExceptionsMap[self._result_dict['error']]
        self._exception = exception_entry[0](
            exception_entry[1] % (self.package, self.call))
    elif self._result_dict['error'] in _ExceptionsMap:
      exception_entry = _ExceptionsMap[self._result_dict['error']]
      self._exception = exception_entry[0](
          exception_entry[1] % (self.package, self.call))
    else:
      try:
        self.response.ParseFromString(self._result_dict['result_string'])
      except Exception, e:
        self._exception = e 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:50,代码来源:apiproxy.py


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