本文整理汇总了Python中multiprocessing.pool.Pool.apply方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.apply方法的具体用法?Python Pool.apply怎么用?Python Pool.apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.pool.Pool
的用法示例。
在下文中一共展示了Pool.apply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manager_process
# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import apply [as 别名]
def manager_process(dir_queue, file_queue, out_queue):
"""Dispatches and manages path and scanning workers.
"""
pool = Pool(options.num_threads)
atexit.register(at_exit_manager, pool)
logging.info('Gathering Files...')
pool.apply(explore_path, (dir_queue, file_queue))
logging.info('Files gathered. Scanning %s files...', file_queue.qsize())
logging.info('Starting %s scan processes...', options.num_threads)
print '~' * 80
thread.start_new_thread(print_status, (file_queue,))
for _ in range(options.num_threads):
pool.apply_async(parallel_scan, (file_queue, out_queue))
pool.close()
pool.join()
out_queue.put(StopIteration)
示例2: query_vehicle_trajetory
# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import apply [as 别名]
def query_vehicle_trajetory(client,numb,ptype,stime,etime):
tgsinfo = read_tgs_info()
# from multiprocessing.dummy import Pool as ThreadPool
from multiprocessing import Pool
pool = Pool()
result = []
for cid in tgsinfo.keys():
result.append(pool.apply(_query_single_bay, (cid,numb,ptype,stime,etime)))
pool.close()
pool.join()
traj = []
for item in result:
for i in item:
traj.append(i)
print 'totally %d records.' % (len(traj))
return traj
示例3: find_item
# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import apply [as 别名]
from multiprocessing.pool import Pool
import os, sys
def find_item(d):
try:
files = os.listdir(d)
except OSError, err:
print(d + ": " + str(err))
else:
print(d)
for item in files:
fullitem = os.path.join(d, item)
if os.path.isdir(fullitem):
tPool.apply_async(find_item, [fullitem])
# findItem(fullitem)
else:
print(fullitem)
if len(sys.argv) > 1:
s_dir = sys.argv[1]
else:
s_dir = "./"
tPool = Pool(2)
tPool.apply(find_item, [s_dir])
tPool.close()
tPool.join()
# findItem(d)