Example #1
0
 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
Example #2
0
 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