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


Python Job.set_priority方法代码示例

本文整理汇总了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
开发者ID:lmr3796,项目名称:CHT-Project-POC-Python-Reimplementation,代码行数:54,代码来源:cht_demo.py


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