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