本文整理汇总了Python中multiprocessing.Process.callback_success方法的典型用法代码示例。如果您正苦于以下问题:Python Process.callback_success方法的具体用法?Python Process.callback_success怎么用?Python Process.callback_success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.Process
的用法示例。
在下文中一共展示了Process.callback_success方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_job
# 需要导入模块: from multiprocessing import Process [as 别名]
# 或者: from multiprocessing.Process import callback_success [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