小编Ire*_*íaz的帖子

使用python在多处理中共享字典

在我的程序中,我需要在使用Python进行多处理的进程之间共享一个字典。我简化了代码,在此举一个例子:

import multiprocessing
def folding (return_dict, seq):
    dis = 1
    d = 0
    ddg = 1 
    '''This is irrelevant, actually my program sends seq parameter to other extern program that returns dis, d and ddg parameters'''
    return_dict [seq] = [dis, d, ddg]

seqs = ['atcgtg', 'agcgatcg', 'atcgatcgatc', atcggatcg', agctgctagct']
manager = Manager()
return_dict = manager.dict()
n_cores = 3

for i in range (0, len(seqs), n_cores) #n_cores is the number of cores availables in the computer, defined by the user
    subseqs …
Run Code Online (Sandbox Code Playgroud)

python dictionary python-multiprocessing

1
推荐指数
1
解决办法
2322
查看次数