示例#1
0
  def _IncrementRetrievalEndedTasksCount(self):
    """Increment sharded counter when each user-retrieval-task ends.

    Returns:
      Final value of the counter after the increment of 1.
    """
    retrieval_ended_count = sharded_counter.IncrementCounterAndGetCount(
        name=view_utils.MakeRetrievalEndedCounterName(self._task_key_id))
    if not retrieval_ended_count:
      view_utils.FailRecallTask(
          task_key_id=self._task_key_id,
          reason_string='Unexpected retrieval_ended count: %s.' %
          retrieval_ended_count,
          raise_exception=True)
    return retrieval_ended_count
示例#2
0
  def handle_exception(self, exception, debug):  # pylint: disable=g-bad-name
    """Common exception handler for webapp2.

    Aborts could flood the log so the aborting code should log an entry as
    this handler will not log the many aborts it sees.

    Args:
      exception: Python Error(Exception) object.
      debug: Boolean; True if the wsgi application has debug enabled.
    """
    if not isinstance(exception, recall_errors.MessageRecallAbortedError):
      _LOG.exception(exception)
      _LOG.debug('Is the web application in debug mode? %s.', debug)
      sharded_counter.IncrementCounterAndGetCount(
          name=view_utils.MakeBackendErrorCounterName(self._task_key_id))
      _LOG.debug('Status=%s.', self.response.status)
      self.response.status = 500
示例#3
0
 def _DecrementRetrievalStartedTasksCount(self):
   """Decrement sharded counter when each user-retrieval-task aborts."""
   sharded_counter.IncrementCounterAndGetCount(
       name=view_utils.MakeRetrievalStartedCounterName(self._task_key_id),
       delta=-1)