在Python concurrent.futures.ProcessPoolExecutor中,如何在父处理器和子处理器之间获得相同的哈希值?

在Python concurrent.futures.ProcessPoolExecutor中,如何在父处理器和子处理器之间获得相同的哈希值?,python,dataframe,dictionary,hash,parallel-processing,Python,Dataframe,Dictionary,Hash,Parallel Processing,在并行计算中,我希望在父处理器和子处理器中获得相同的数据帧哈希值。然而,我不能得到同样的。下面显示了我的代码: from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor import pandas as pd import os def process(x): df = pd.DataFrame([1, 'abghhhj']) print(hash(str(df.values.tolist())

在并行计算中,我希望在父处理器和子处理器中获得相同的数据帧哈希值。然而,我不能得到同样的。下面显示了我的代码:

from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
import pandas as pd
import os
def process(x):

    df = pd.DataFrame([1, 'abghhhj'])
    print(hash(str(df.values.tolist())))
    return df

def main():

    executor = [ProcessPoolExecutor, ThreadPoolExecutor][0]
    df = pd.DataFrame([1, 'abghhhj'])
    with executor(max_workers=2) as executor:
        executor.map(process,range(2))
    for i in range(2):
        print(hash(str(df.values.tolist())))

if __name__ == '__main__':

    os.environ['PYTHONHASHSEED'] = '0'
    main()
我知道如果我

os.environ['PYTHONHASHSEED'] = '0'
那么哈希值在所有子处理器上都是相同的。但是父处理器和子处理器之间的哈希值仍然不同

有什么建议吗?如果您对此没有答案,您能告诉我如何将dataframe转换为字典的键吗?我需要最快的方法来做,因为我的模型是时间敏感的。提前谢谢