def _store_result(self, task_id, result, state, traceback=None, max_retries=3, **kwargs): request = kwargs.get('request', {}) session = self.ResultSession() with session_cleanup(session): task = list(session.query(Task).filter(Task.task_id == task_id)) task = task and task[0] if not task: task = Task(task_id) session.add(task) session.flush() task.result = result task.status = state task.traceback = traceback task.task_name = repr(getattr(request, 'task', None)) _args = self.get_args(getattr(request, 'args', [])) task.task_args = repr(_args) task.task_kwargs = repr(getattr(request, 'kwargs', None)) session.commit() return result
def _get_task_meta_for(self, task_id): """Get task meta-data for a task by id.""" session = self.ResultSession() with session_cleanup(session): task = list(session.query(Task).filter(Task.task_id == task_id)) task = task and task[0] if not task: task = Task(task_id) task.status = states.PENDING task.result = None return self.meta_from_decoded(task.to_dict())
def _store_result(self, task_id, result, state, traceback=None, max_retries=3, **kwargs): """Store return value and state of an executed task.""" session = self.ResultSession() with session_cleanup(session): task = list(session.query(Task).filter(Task.task_id == task_id)) task = task and task[0] if not task: task = Task(task_id) session.add(task) session.flush() task.result = result task.status = state task.traceback = traceback session.commit() return result