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


Python ThreadPool.kill方法代码示例

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


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

示例1: randrange

# 需要导入模块: from ThreadPool import ThreadPool [as 别名]
# 或者: from ThreadPool.ThreadPool import kill [as 别名]
            d = randrange(1, 10)  # sleep up to 10 sec
            try:
                logger.info('Adding task: sleep for %d secs (task %d)', d, task_num)
                pool.add_task(user, wait_delay, d, task_num)
                real_time_for_jobs += d
            except Exception as e:
                logging.warning(e)
            task_num += 1
            time.sleep(delay)
        logger.info('user %s submitted jobs for %d secs', user, real_time_for_jobs)


    # 1) Init a Thread pool with the desired number of threads and number of users
    pool = ThreadPool(num_of_process, num_of_users, sched_policy, queue_policy)
    producers = []

    for user in range(num_of_users):
        base_time = 20.0  # the slowest user
        delay = base_time / (user + 1)
        p = Process(target=producer, args=(pool, user, delay,))
        producers.append(p)
        p.start()

    # 3) Wait for completion
    [p.join() for p in producers]

    pool.kill()
    pool.wait_completion()

    pool.scheduler.print_statistics()
开发者ID:YehudaItkin,项目名称:python-threadpool-with-priorities,代码行数:32,代码来源:TP_main.py


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