本文整理汇总了Python中job.Job.set_priority方法的典型用法代码示例。如果您正苦于以下问题:Python Job.set_priority方法的具体用法?Python Job.set_priority怎么用?Python Job.set_priority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类job.Job
的用法示例。
在下文中一共展示了Job.set_priority方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import set_priority [as 别名]
def main():
total_deadline = int(sys.argv[1])
delay = int(sys.argv[2])
wc_job = Job('word count')
bzip2_job = Job('bzip2')
h264_job = Job('h264')
for i in range(20):
wc_job.add_task(RUN_PATH + '/word_count.sh')
for i in range(10):
bzip2_job.add_task(RUN_PATH + '/bzip2.sh')
for i in range(4):
h264_job.add_task(RUN_PATH + '/h264.sh')
for worker in config.workers:
wc_job.set_per_server_time(worker, WC_PER_TASK_RUNNING_TIME)
bzip2_job.set_per_server_time(worker, BZIP2_PER_TASK_RUNNING_TIME)
h264_job.set_per_server_time(worker, H264_PER_TASK_RUNNING_TIME)
wc_job.set_priority(3)
bzip2_job.set_priority(2)
h264_job.set_priority(1)
# First batch
print 'Dispatching first batch'
job_set = [wc_job]
for j in job_set:
j.set_deadline(total_deadline)
schedule = framework.get_dispatcher().schedule_jobs(job_set)
print schedule
t1 = Thread(target=framework.run_job_set, args=(job_set,))
t1.start()
# Simulate gap between job arrival
time.sleep(delay)
# Second batch
print 'Dispatching second batch'
job_set = [bzip2_job, h264_job]
for j in job_set:
j.set_deadline(total_deadline - delay)
schedule = framework.get_dispatcher().schedule_jobs(job_set)
print schedule
t2 = Thread(target=framework.run_job_set, args=(job_set,))
t2.start()
# Wait till finish
t1.join()
t2.join()
return 0