Python多处理池imap\u无序

2024-04-19 01:03:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Python多处理池imap\u unordered。你知道吗

在生成器中,我将输入列表填充到fillInputList中,并将此输入列表发送到prepare\u data\u fill\u arrays

准备\数据\填充\数组需要很长时间,它读取文件并填充数组。你知道吗

当数组被填充时,我将它们累加到累计数组中

fillInputListprepare\u data\u fill\u arrays都有打印行,显示它们已进入函数。你知道吗

但是,没有一个是书面的,只有:

  • 累加中的Worker PID XXXX

  • 累加中的Worker PID XXXX

这些都是写好的。你知道吗

原因可能是,它不等待准备数据\u填充数组完成。你知道吗

numofSimulations=10
chromNamesList=['chr1', 'chr2', 'chr3', 'chr4', 'chr5', 'chr6', 'chr7', 'chrX', 'chr8', 'chr9', 'chr10', 'chr11', 'chr12', 'chr13', 'chr14', 'chr15', 'chr16', 'chr17', 'chr18', 'chr20', 'chrY', 'chr19', 'chr22', 'chr21', 'chrM']
sim_nums = range(0, numofSimulations+1)
sim_num_chr_tuples=((sim_num,chrLong) for sim_num in sim_nums for chrLong in chromNamesList)

for arrayList in pool.imap_unordered(prepare_data_fill_arrays, (fillInputList(simNum,chrLong,x,y,z,a,b,c) for simNum,chrLong in sim_num_chr_tuples),chunksize=1):

    print('Worker pid %s in accumulate' %str(os.getpid()))
    array1 = arrayList[0]
    array2 = arrayList[1]
    accumulateArray(accumulatedArray1, array1)
    accumulateArray(accumulatedArray2, array2) 

Tags: infordatasim数组preparefillnum