예제 #1
0
    def put_status(self, status):
        # Try to collect rusage at this point, when process is still alive
        try:
            kinfo = bsd.kinfo_getproc(self.pid)
            self.task.rusage = kinfo.rusage
        except LookupError:
            pass

        if status['status'] == 'ROLLBACK':
            self.task.set_state(TaskState.ROLLBACK)

        if status['status'] == 'FINISHED':
            self.result.set(status['result'])

        if status['status'] == 'FAILED':
            error = status['error']
            cls = TaskException

            if error['type'] == 'task.TaskAbortException':
                cls = TaskAbortException

            if error['type'] == 'ValidationException':
                cls = ValidationException

            self.result.set_exception(cls(
                code=error['code'],
                message=error['message'],
                stacktrace=error['stacktrace'],
                extra=error.get('extra')
            ))
예제 #2
0
파일: main.py 프로젝트: lukegb/middleware
    def pid_exec(self, ev):
        try:
            proc = bsd.kinfo_getproc(self.pid)
            argv = list(proc.argv)
            command = proc.command
        except (LookupError, ProcessLookupError):
            # Exited too quickly, exit info will be catched in another event
            return

        self.logger.debug('Job did exec() into {0}'.format(argv))

        if self.anonymous:
            # Update label for anonymous jobs
            self.label = 'anonymous.{0}@{1}'.format(command, self.pid)
            self.logger = logging.getLogger('Job:{0}'.format(self.label))

        if self.state == JobState.STARTING:
            with self.cv:
                try:
                    self.sid = os.getsid(self.pid)
                    self.pgid = os.getpgid(self.pid)
                except ProcessLookupError:
                    # Exited too quickly after exec()
                    return

                if not self.supports_checkin:
                    self.set_state(JobState.RUNNING)
                    self.context.provide(self.provides)
예제 #3
0
파일: main.py 프로젝트: erinix/middleware
    def pid_exec(self, ev):
        try:
            proc = bsd.kinfo_getproc(self.pid)
            argv = list(proc.argv)
            command = proc.command
        except (LookupError, ProcessLookupError):
            # Exited too quickly, exit info will be catched in another event
            return

        self.logger.debug('Job did exec() into {0}'.format(argv))

        if self.anonymous:
            # Update label for anonymous jobs
            self.label = 'anonymous.{0}@{1}'.format(command, self.pid)
            self.logger = logging.getLogger('Job:{0}'.format(self.label))

        if self.state == JobState.STARTING:
            with self.cv:
                try:
                    self.sid = os.getsid(self.pid)
                    self.pgid = os.getpgid(self.pid)
                except ProcessLookupError:
                    # Exited too quickly after exec()
                    return

                if not self.supports_checkin:
                    self.set_state(JobState.RUNNING)
                    self.context.provide(self.provides)
예제 #4
0
파일: main.py 프로젝트: jceel/middleware
    def debug_process(self, pid, gdb, fd):
        try:
            proc = bsd.kinfo_getproc(pid)
        except LookupError:
            raise RpcException(errno.ENOENT, 'PID {0} not found'.format(pid))

        self.context.run_job(DebugServerConnection(pid, gdb, fd))
        return proc.path
예제 #5
0
파일: main.py 프로젝트: freenas/middleware
    def debug_process(self, pid, gdb, fd):
        try:
            proc = bsd.kinfo_getproc(pid)
        except LookupError:
            raise RpcException(errno.ENOENT, "PID {0} not found".format(pid))

        self.context.run_job(DebugServerConnection(pid, gdb, fd))
        return proc.path
예제 #6
0
파일: main.py 프로젝트: lukegb/middleware
    def push(self, entry):
        creds = get_sender().credentials
        if creds:
            entry['pid'] = creds['pid']
            entry['uid'] = creds['uid']
            entry['gid'] = creds['gid']

        if 'identifier' not in entry:
            try:
                proc = kinfo_getproc(entry['pid'])
                entry['identifier'] = proc.command
            except OSError:
                entry['identifier'] = 'unknown'

        entry['source'] = 'rpc'
        self.context.push(entry)
예제 #7
0
파일: main.py 프로젝트: erinix/middleware
    def push(self, entry):
        creds = get_sender().credentials
        if creds:
            entry['pid'] = creds['pid']
            entry['uid'] = creds['uid']
            entry['gid'] = creds['gid']

        if 'identifier' not in entry:
            try:
                proc = kinfo_getproc(entry['pid'])
                entry['identifier'] = proc.command
            except OSError:
                entry['identifier'] = 'unknown'

        entry['source'] = 'rpc'
        self.context.push(entry)
예제 #8
0
파일: main.py 프로젝트: lukegb/middleware
    def load_anonymous(self, parent, pid):
        try:
            proc = bsd.kinfo_getproc(pid)
            command = proc.command
        except (LookupError, ProcessLookupError):
            # Exited too quickly, but let's add it anyway - it will be removed in next event
            command = 'unknown'

        with self.cv:
            self.parent = parent
            self.id = str(uuid.uuid4())
            self.pid = pid
            self.label = 'anonymous.{0}@{1}'.format(command, self.pid)
            self.logger = logging.getLogger('Job:{0}'.format(self.label))
            self.anonymous = True
            self.state = JobState.RUNNING
            self.cv.notify_all()
예제 #9
0
파일: main.py 프로젝트: erinix/middleware
    def load_anonymous(self, parent, pid):
        try:
            proc = bsd.kinfo_getproc(pid)
            command = proc.command
        except (LookupError, ProcessLookupError):
            # Exited too quickly, but let's add it anyway - it will be removed in next event
            command = 'unknown'

        with self.cv:
            self.parent = parent
            self.id = str(uuid.uuid4())
            self.pid = pid
            self.label = 'anonymous.{0}@{1}'.format(command, self.pid)
            self.logger = logging.getLogger('Job:{0}'.format(self.label))
            self.anonymous = True
            self.state = JobState.RUNNING
            self.cv.notify_all()
예제 #10
0
    def put_status(self, status):
        # Try to collect rusage at this point, when process is still alive
        try:
            kinfo = bsd.kinfo_getproc(self.pid)
            self.task.rusage = kinfo.rusage
        except LookupError:
            pass

        if status['status'] == 'FINISHED':
            self.result.set(status['result'])

        if status['status'] == 'FAILED':
            error = status['error']
            self.result.set_exception(TaskException(
                code=error['code'],
                message=error['message'],
                stacktrace=error['stacktrace'],
                extra=error.get('extra')
            ))