Пример #1
0
    def _run(self):
        """
        Run the call in the call request.
        Generally the target of a new thread.
        """
        # used for calling _run directly during testing
        principal_manager = managers_factory.principal_manager()
        principal_manager.set_principal(self.call_request.principal)

        # generally set in the wrapper, but not when called directly
        if self.call_report.state in dispatch_constants.CALL_READY_STATES:
            self.call_report.state = dispatch_constants.CALL_RUNNING_STATE

        self.call_report.start_time = datetime.datetime.now(dateutils.utc_tz())

        dispatch_context.CONTEXT.set_task_attributes(self)

        call = self.call_request.call
        args = copy.copy(self.call_request.args)
        kwargs = copy.copy(self.call_request.kwargs)

        try:
            result = call(*args, **kwargs)

        except:
            e, tb = sys.exc_info()[1:]
            _LOG.exception(e)
            return self._failed(e, tb)

        else:
            return self._succeeded(result)

        finally:
            principal_manager.clear_principal()
            dispatch_context.CONTEXT.clear_task_attributes()
Пример #2
0
 def _run(self):
     """
     Run the call in the call request.
     Generally the target of a new thread.
     """
     # used for calling _run directly during testing
     principal_manager = managers_factory.principal_manager()
     principal_manager.set_principal(self.call_request.principal)
     # usually set in the wrapper, unless called directly
     if self.call_report.state in dispatch_constants.CALL_READY_STATES:
         self.call_report.state = dispatch_constants.CALL_RUNNING_STATE
     self.call_report.start_time = datetime.datetime.now(dateutils.utc_tz())
     dispatch_context.CONTEXT.set_task_attributes(self)
     call = self.call_request.call
     args = copy.copy(self.call_request.args)
     kwargs = copy.copy(self.call_request.kwargs)
     try:
         result = call(*args, **kwargs)
     except:
         # NOTE: this is making an assumption here that the call failed to
         # execute, if this isn't the case, or it got far enough, we may be
         # faced with _succeeded or _failed being called again
         e, tb = sys.exc_info()[1:]
         _LOG.exception(e)
         # too bad 2.4 doesn't support try/except/finally blocks
         principal_manager.clear_principal()
         dispatch_context.CONTEXT.clear_task_attributes()
         return self._failed(e, tb)
     principal_manager.clear_principal()
     dispatch_context.CONTEXT.clear_task_attributes()
     return result
Пример #3
0
    def _run(self):
        """
        Run the call in the call request.
        Generally the target of a new thread.
        """
        # used for calling _run directly during testing
        principal_manager = managers_factory.principal_manager()
        principal_manager.set_principal(self.call_request.principal)

        # generally set in the wrapper, but not when called directly
        if self.call_report.state in dispatch_constants.CALL_READY_STATES:
            self.call_report.state = dispatch_constants.CALL_RUNNING_STATE

        self.call_report.start_time = datetime.datetime.now(dateutils.utc_tz())

        dispatch_context.CONTEXT.set_task_attributes(self)

        call = self.call_request.call
        args = copy.copy(self.call_request.args)
        kwargs = copy.copy(self.call_request.kwargs)

        try:
            result = call(*args, **kwargs)

        except:
            e, tb = sys.exc_info()[1:]
            _LOG.exception(e)
            return self._failed(e, tb)

        else:
            return self._succeeded(result)

        finally:
            principal_manager.clear_principal()
            dispatch_context.CONTEXT.clear_task_attributes()
Пример #4
0
    def _run(self):
        """
        Run the call in the call request.
        Generally the target of a new thread.
        """

        # used for calling _run directly during testing
        principal_manager = managers_factory.principal_manager()
        principal_manager.set_principal(self.call_request.principal)

        # usually set in the wrapper, unless called directly
        if self.call_report.state in dispatch_constants.CALL_READY_STATES:
            self.call_report.state = dispatch_constants.CALL_RUNNING_STATE

        self.call_report.start_time = datetime.datetime.now(dateutils.utc_tz())

        dispatch_context.CONTEXT.set_task_attributes(self)

        call = self.call_request.call
        args = copy.copy(self.call_request.args)
        kwargs = copy.copy(self.call_request.kwargs)

        try:
            result = call(*args, **kwargs)

        except:
            # NOTE: this is making an assumption here that the call failed to
            # execute, if this isn't the case, or it got far enough, we may be
            # faced with _succeeded or _failed being called again
            e, tb = sys.exc_info()[1:]
            _LOG.exception(e)
            return self._failed(e, tb)

        else:
            return result

        finally:
            principal_manager.clear_principal()
            dispatch_context.CONTEXT.clear_task_attributes()
Пример #5
0
 def _run(self):
     """
     Run the call in the call request.
     Generally the target of a new thread.
     """
     # used for calling _run directly during testing
     if self.call_report.state in dispatch_constants.CALL_READY_STATES:
         self.call_report.state = dispatch_constants.CALL_RUNNING_STATE
     self.call_report.start_time = datetime.datetime.now(dateutils.utc_tz())
     dispatch_context.CONTEXT.set_task_attributes(self)
     call = self.call_request.call
     args = copy.copy(self.call_request.args)
     kwargs = copy.copy(self.call_request.kwargs)
     try:
         result = call(*args, **kwargs)
     except:
         e, tb = sys.exc_info()[1:]
         _LOG.exception(e)
         # to bad 2.4 doesn't support try/except/finally blocks
         dispatch_context.CONTEXT.clear_task_attributes()
         return self._failed(e, tb)
     dispatch_context.CONTEXT.clear_task_attributes()
     return self._succeeded(result)