コード例 #1
0
ファイル: job.py プロジェクト: helicontech/zoo
    def setup_job(self, job_id: int):
        # method that clean some garbage
        if self.current_job is not None:
            self.current_job.status = JobPeewee.STATUS_DONE
            self.current_job.save()

        self.current_job = JobPeewee.get(JobPeewee.id == job_id)
        self.current_job.status = JobPeewee.STATUS_RUNNING
        self.current_job.save()
コード例 #2
0
    def get_running_job():

        ret = Core.get_lock(JobDataModel.LOCK)
        if not ret:
            return None
        else:
            job_id = int(ret)
            try:
                job = JobDataModel.get(JobDataModel.id == job_id)
                return job
            except JobDataModel.DoesNotExist:
                return None
コード例 #3
0
ファイル: task_manager.py プロジェクト: helicontech/zoo
    def get_running_job():

        ret = Core.get_lock(JobDataModel.LOCK)
        if not ret:
            return None
        else:
            job_id = int(ret)
            try:
                job = JobDataModel.get(JobDataModel.id == job_id)
                return job
            except JobDataModel.DoesNotExist:
                return None
コード例 #4
0
ファイル: task_manager.py プロジェクト: helicontech/zoo
    def is_job_alive(core, job_id):

        try:
            obj = JobDataModel.get(JobDataModel.id == job_id)
            # may be wrong
            logging.debug("find possible alive task %i pid is %i %s" % (job_id, obj.pid, obj.status))

            if obj.status == JobDataModel.STATUS_EXCEPTION:
                return False
            if obj.status == JobDataModel.STATUS_FAILED:
                return False
            if obj.status == JobDataModel.STATUS_DONE:
                return False

            pid = obj.pid

            return core.api.os.shell.is_alive(pid)
        except JobDataModel.DoesNotExist:
            return False
コード例 #5
0
    def is_job_alive(core, job_id):

        try:
            obj = JobDataModel.get(JobDataModel.id == job_id)
            # may be wrong
            logging.debug("find possible alive task %i pid is %i %s" %
                          (job_id, obj.pid, obj.status))

            if obj.status == JobDataModel.STATUS_EXCEPTION:
                return False
            if obj.status == JobDataModel.STATUS_FAILED:
                return False
            if obj.status == JobDataModel.STATUS_DONE:
                return False

            pid = obj.pid

            return core.api.os.shell.is_alive(pid)
        except JobDataModel.DoesNotExist:
            return False