当前位置: 首页>>代码示例>>Python>>正文


Python Process.process_number方法代码示例

本文整理汇总了Python中multiprocessing.Process.process_number方法的典型用法代码示例。如果您正苦于以下问题:Python Process.process_number方法的具体用法?Python Process.process_number怎么用?Python Process.process_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.Process的用法示例。


在下文中一共展示了Process.process_number方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_job

# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import process_number [as 别名]
    def process_job(self, job):
        """
        Method used to launch a job in a separate process
        """
        self.log_info('Found one %s job. Launching processing...' % job.status)

        process_number = self.process_number_list.pop(0)

        proc = None

        def check_job_success():
            try:
                self.current_job_processes.remove(proc)
                self.process_number_list.append(process_number)
            except:
                pass
            job.reload()
            self.log_debug("Job %s success callback : %s" % (job.uuid, job.status))
            if job.status not in ['success', 'error']:
                job.status = "success"
                job.status_text = "Job Successful"
                job.completion = 100
                job.save()
                #job.save_as_successful()

        def check_job_error(exitcode):
            try:
                self.current_job_processes.remove(proc)
                self.process_number_list.append(process_number)
            except:
                pass
            job.reload()
            self.log_error("Job %s ERROR callback" % (job.uuid))
            if job.status != 'error':
                job.details = "Error (callback) : exitcode=%s" % str(exitcode)
                job.status = "error"
                job.status_text = "Error - exitcode=%s" % str(exitcode)
                job.save()

        # Detach non-serializable thread/lock arguments
        status_update_stopper = self.status_update_stopper
        self.status_update_stopper = None

        # Start process
        proc = Process(
            name="Process-%02d-%s" % (process_number, job.uuid),
            target=launch_job,
            args=(job, process_number, self)
        )
        proc.start()

        # Reattach non-serializable thread/lock arguments
        self.status_update_stopper = status_update_stopper

        proc.job = job
        proc.process_number = process_number
        proc.callback_success = check_job_success
        proc.callback_error = check_job_error

        self.current_job_processes.append(proc)
        return
开发者ID:ronhanson,项目名称:python-jobmanager-client,代码行数:63,代码来源:client.py


注:本文中的multiprocessing.Process.process_number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。