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()
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()
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()
def thread_factory(callable): raise exception.ResourceExhausted("Too many tasks", resource="test", current_tasks=0)
def dispatch(callable, timeout=None): raise exception.ResourceExhausted(resource="test", current_tasks=0)