Exemplo n.º 1
0
    def after_return(self, status, retval, task_id, args, kwargs, einfo):
        """Handler called after the task returns.

        Parameters:

            status - Current task state.
            retval - Task return value/exception.
            task_id - Unique id of the task.
            args - Original arguments for the task that returned.
            kwargs - Original keyword arguments for the task that returned.
            einfo - ExceptionInfo instance, containing the traceback (if any).

        The return value of this handler is ignored.
        """
        BaseTask.after_return(
            self,
            status,
            retval,
            task_id,
            args,
            kwargs,
            einfo)

        if operation.session is not None:
            self._release_session()
Exemplo n.º 2
0
    def on_failure(self, exc, task_id, args, kwargs, einfo):
        """This is run by the worker when the task fails.
        
        Parameters:
    
            exc - The exception raised by the task.
            task_id - Unique id of the failed task.
            args - Original arguments for the task that failed.
            kwargs - Original keyword arguments for the task that failed.
            einfo - ExceptionInfo instance, containing the traceback.
    
        The return value of this handler is ignored.
        """
        BaseTask.on_failure(self, exc, task_id, args, kwargs, einfo)

        err = str(exc)
        trace = format_tb(einfo.tb)
        trace.append(err)
        self.update(u'FAILURE', ex=err, traceback=trace, result=None, msg=err)
Exemplo n.º 3
0
    def on_failure(self, exc, task_id, args, kwargs, einfo):
        """This is run by the worker when the task fails.

        Parameters:

            exc - The exception raised by the task.
            task_id - Unique id of the failed task.
            args - Original arguments for the task that failed.
            kwargs - Original keyword arguments for the task that failed.
            einfo - ExceptionInfo instance, containing the traceback.

        The return value of this handler is ignored.
        """
        err = exc
        BaseTask.on_failure(self, exc, task_id, args, kwargs, einfo)
        trace = format_tb(einfo.tb)
        trace.append(err)
        logger.error('', exc_info=1)
        self.update_job(params={}, status='FAILURE', current_time=time(), ex=err, traceback=trace,
                        result=None, msg=err)
Exemplo n.º 4
0
 def set_shared_data(self, data, job=None):
     """ """
     if job is None:
         job = task_local.opid
     data = BaseTask.set_shared_data(self, job, data)
     return data
Exemplo n.º 5
0
 def get_shared_data(self, job=None):
     """ """
     if job is None:
         job = task_local.opid
     data = BaseTask.get_shared_data(self, job)
     return data
Exemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     BaseTask.__init__(self, *args, **kwargs)
Exemplo n.º 7
0
 def remove_stack(self):
     """Remove shared memory stack reference from redis"""
     return BaseTask.remove_stack(self, task_local.opid)
Exemplo n.º 8
0
 def push_stack_data(self, data):
     """Set data to shared memory stack. Use this to pass data from different
     tasks that must ensure synchronization.
     """
     return BaseTask.push_stack_data(self, task_local.opid, data)
Exemplo n.º 9
0
 def pop_stack_data(self):
     """Pop item from shared memory stack. Use this to pass data from different
     tasks that must ensure synchronization.
     """
     return BaseTask.pop_stack_data(self, task_local.opid)
Exemplo n.º 10
0
 def remove_shared_area(self):
     """ """
     return BaseTask.remove_shared_area(self, task_local.opid)
Exemplo n.º 11
0
 def set_shared_data(self, data):
     """ """
     current_data = self.get_shared_data()
     current_data.update(data)
     return BaseTask.set_shared_data(self, task_local.opid, current_data)
Exemplo n.º 12
0
 def get_shared_data(self):
     """ """
     data = BaseTask.get_shared_data(self, task_local.opid)
     return data