本文整理汇总了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()