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


Python ProcessingPool.amap方法代码示例

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


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

示例1: C

# 需要导入模块: from pathos.multiprocessing import ProcessingPool [as 别名]
# 或者: from pathos.multiprocessing.ProcessingPool import amap [as 别名]
class C(object):
    def __init__(self,files):
        self.pool = Pool(4)
        self.files = files

    def raw_processor(self, fi,prefix,somedict):
        df = pd.read_table(
                fi,
                header=None,
                names=['artist_id','ts'],
                parse_dates=['ts'])\
            .sort_values(by='ts')
        user = fi.split('/')[-1][:-4]
        df.to_pickle('/Users/jaredlorince/git/MusicForaging/testData/scrobbles_test/{}_{}.pkl'.format(prefix,user))
        rootLogger.info('preprocessing complete for user {} ({})'.format(user,fi))

    def run_p(self):
        func_partial = partial(self.raw_processor,prefix='blah',somedict=d)
        result = self.pool.amap(func_partial, self.files)
开发者ID:jlorince,项目名称:MusicForaging,代码行数:21,代码来源:debug.py

示例2: print

# 需要导入模块: from pathos.multiprocessing import ProcessingPool [as 别名]
# 或者: from pathos.multiprocessing.ProcessingPool import amap [as 别名]
        regex_search.save_regex(args.save_regex[0])
    elif args.existing_regex is not None:
        regex_search.load_regex(args.existing_regex[0])
    print("Loaded %d regex in %d seconds!" % (len(regex_search.regex), time.time() - start_regex_time))
    start_regex_time = None
    logging.info("Starting searches")

    #results = search_regex(regex_worker, regex_res, fastq_file, args.cpus)
    if __name__ == '__main__':
        result_1 = []
        output_1 = []

        if args.multithread is True:
            # errors = Queue()
            p = Pool(nodes=args.cpus[0])
            res = p.amap(regex_worker_multithread, fastq_file.sequences)
            count = 0
            while not res.ready():
                count += 2
                print("\rWaiting. Timer: %d" % count, end='')
                time.sleep(2)
            # for e in errors.get():
            #     print(e)
            # p.terminate()
            result_1 = res.get()
            print("\nDone searching")

        elif args.multithread is False:
            num_seq = 0
            for seq in fastq_file.sequences:
                num_seq += 1
开发者ID:fazzertron,项目名称:SatCom,代码行数:33,代码来源:process_sequences.py

示例3: ProcessingPool

# 需要导入模块: from pathos.multiprocessing import ProcessingPool [as 别名]
# 或者: from pathos.multiprocessing.ProcessingPool import amap [as 别名]
# instantiate and configure the worker pool
from pathos.multiprocessing import ProcessingPool
pool = ProcessingPool(nodes=4)

_result = map(pow, [1,2,3,4], [5,6,7,8]) 

# do a blocking map on the chosen function
result = pool.map(pow, [1,2,3,4], [5,6,7,8])
assert result == _result

# do a non-blocking map, then extract the result from the iterator
result_iter = pool.imap(pow, [1,2,3,4], [5,6,7,8])
result = list(result_iter)
assert result == _result

# do an asynchronous map, then get the results
result_queue = pool.amap(pow, [1,2,3,4], [5,6,7,8])
result = result_queue.get()
assert result == _result

开发者ID:WarrenWeckesser,项目名称:pathos,代码行数:21,代码来源:test_mp.py


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