Python google.appengine.ext.db 模块,Timeout() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用google.appengine.ext.db.Timeout()

项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def flush(self):
    """Force a flush."""
    if not self.items:
      return

    retry = 0
    options = {"deadline": DATASTORE_DEADLINE}
    while retry <= self.__timeout_retries:
      try:
        self.__flush_function(self.items, options)
        self.clear()
        break
      except db.Timeout, e:
        logging.warning(e)
        logging.warning("Flushing '%s' timed out. Will retry for the %s time.",
                        self, retry)
        retry += 1
        options["deadline"] *= 2
      except apiproxy_errors.RequestTooLargeError:
        self._log_largest_items()
        raise
    else:
      raise
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def generate_edges_page(ndb_iter, page_size, keys_only, edge_type):
    edges = []
    timeouts = 0
    while len(edges) < page_size:
        try:
            entity = ndb_iter.next()
        except StopIteration:
            break
        except Timeout:
            timeouts += 1
            if timeouts > 2:
                break

            continue
        except DeadlineExceededError:
            break

        if keys_only:
            # entity is actualy an ndb.Key and we need to create an empty entity to hold it
            entity = edge_type._meta.fields['node']._type._meta.model(key=entity)

        edges.append(edge_type(node=entity, cursor=ndb_iter.cursor_after().urlsafe()))

    return edges
项目:beg-django-e-commerce    作者:Apress    | 项目源码 | 文件源码
def process_exception(self, request, exception):
        if isinstance(exception, CapabilityDisabledError):
            return maintenance(request)
        elif isinstance(exception, db.Timeout):
            return server_error(request)