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


Python Pool.apply方法代码示例

本文整理汇总了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)
开发者ID:bashcode,项目名称:Pyscan,代码行数:19,代码来源:pyscan.py

示例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
开发者ID:xlees,项目名称:TgsVis,代码行数:24,代码来源:trajetory.py

示例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)
开发者ID:slaash,项目名称:scripts,代码行数:32,代码来源:find_thr.py


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