class DummyProbe(Probe): def __init__(self): self.task = Task('test:task', context={ 'monitor': { 'name': 'true_monitor' } }) self.results_iter = iter(result_codes) def get_task(self, **kwargs): return self.task def resubmit_task(self, task, delay, **kwargs): self.task.increment_attempt() def submit_result(self, result, **kwargs): if result.state_type == results.HARD: self.task.attempt = 0 return result def execute_task(self, task, timeout, **kwargs): result = results.Result(task.id, timestamp=task.created, task_context=task.context) result.state = next(self.results_iter) result.output = 'Some output here.' return result
def __init__(self): self.task = Task('test:task', context={ 'monitor': { 'name': 'true_monitor' } }) self.results_iter = iter(result_codes)
def get_task(self, **kwargs): self._setup_queue(**kwargs) wait_time = kwargs.get('queue_wait_time') timeout = kwargs.get('monitor_timeout') + 3 logger.debug("Getting task from queue %s.", self._queue_name) task_item = self._queue.read(visibility_timeout=timeout, wait_time_seconds=wait_time) task = None if task_item: task = Task.deserialize(json.loads(task_item.get_body()), origin=task_item) return task