gpt4 book ai didi

Python 2.7 多处理障碍

转载 作者:太空宇宙 更新时间:2023-11-03 15:09:45 24 4
gpt4 key购买 nike

我正在使用 Python 2.7,并且一直在将多线程代码转换为多处理代码以避免 GIL 锁定问题。但是,我在多处理模块中没有看到屏障实现(有什么想法可以实现吗?)。

我看到了这个问题: Is it possible to use multiprocessing.Event to implement a synchronization barrier for pool of processes?但我不确定它是否会正常工作,因为它不使用任何锁!

谢谢!

最佳答案

我很确定 multiprocessing 包的内置同步原语提供了您所需要的:https://docs.python.org/2/library/multiprocessing.html#synchronization-primitives

关于Python 2.7 多处理障碍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28375646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com