python 多进程报错:Can‘t pickle<function ISC>
2021/12/21 7:21:15
本文主要是介绍python 多进程报错:Can‘t pickle<function ISC>,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
各位大佬好,我在使用python多进程的时候遇到了一个问题
def multi_process(): # with ProcessPoolExecutor() as pool: # pool = mp.Pool(mp.cpu_count()) with mp.Pool() as pool: pool.starmap(ISC, [(l, t) for l in range(2 * brCount) for t in range(Time)]) if __name__ == "__main__": for_start = time.time() multi_process() for_end = time.time()
函数ISC定义为:
def ISC(l, t): global ISCR_C ISCR_C[:, 0] = ISCR_A[l, :] ISCR_C[:, 1] = ISCR_Pmax ISCR_C = ISCR_C[np.lexsort(-ISCR_C[:, ::-1].T)] if l <= brCount - 1: for k in range(GenCount - 1): if ISCR1(k, t) * ISCR2(k, t) * ISCR3(l, k, t) == 1: opt.remove_constraint(model.branch_Cap1[t, l]) break else: for k in range(GenCount - 1): if ISCR1(k, t) * ISCR2(k, t) * ISCR3(l, k, t) == 1: opt.remove_constraint(model.branch_Cap2[t,l - brCount]) break
程序运行会报错:
第一次用多进程,除了问题也不知咋回事,有没有大佬能救救孩子
这篇关于python 多进程报错:Can‘t pickle<function ISC>的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-27使用python 将ETH账户的资产打散
- 2024-09-26Python编程基础
- 2024-09-2610 种方法写出更好的 Python 代码
- 2024-09-25Python编程基础详解
- 2024-09-25Python编程入门教程
- 2024-09-25从零开始使用Python构建LLaMA 3
- 2024-09-23Python中理解和使用树形结构的简单教程
- 2024-09-23Python 编程基础入门
- 2024-09-18初探Python股票自动化交易:入门指南
- 2024-09-18Python量化入门:轻松掌握量化分析基础与实战