Ejemplo n.º 1
0
 def dispatch(self, func, timeout, discard=True):
     self.attempts += 1
     exhausted = self._tries_before_success > 0
     if exhausted:
         self._tries_before_success -= 1
         raise exception.ResourceExhausted(resource="test", current_tasks=0)
     else:
         func()
Ejemplo n.º 2
0
    def dispatch(self, func, timeout, discard=True):
        if (self._max_attempts is not None and
           self.attempts == self._max_attempts):
            self.done.set()

        self.attempts += 1

        if self._fail:
            raise exception.ResourceExhausted(resource="test", current_tasks=0)
        else:
            func()
Ejemplo n.º 3
0
 def put(self, task):
     """
     Put a new task in the queue.
     Do not block when full, raises ResourceExhausted instead.
     """
     with self._cond:
         if len(self._tasks) == self._max_tasks:
             raise exception.ResourceExhausted(
                 "Too many tasks",
                 resource=self._name,
                 current_tasks=self._max_tasks)
         self._tasks.append(task)
         self._cond.notify()
Ejemplo n.º 4
0
 def thread_factory(callable):
     raise exception.ResourceExhausted("Too many tasks",
                                       resource="test",
                                       current_tasks=0)
Ejemplo n.º 5
0
def dispatch(callable, timeout=None):
    raise exception.ResourceExhausted(resource="test", current_tasks=0)