同时启动 3 个带参数的不同函数

Launch 3 distinct functions with arguments at the same time

我想在多核机器上同时启动 3 个不同的功能。每个函数都使用相同的模块 (cx_Oracle) 启动广泛的数据查询以分离数据库,并且每个函数都使用一些参数调用。这是如何实现的?

我读过一些关于 Python 的并行计算,但 ProcessPoolExecutor 总是 returns BrokenProcessPool 错误。脚本已保存(在其他 SE 项目中报告为问题)。

if __name__ == '__main__'
    with ProcessPoolExecutor(3) as executor:
        future_1 = executor.submit(query_1, arg1)
        future_2 = executor.submit(query_2, arg2)
        future_3 = executor.submit(query_3, arg3)
    result_1 = future_1.result()
    result_2 = future_2.result()
    result_3 = future_3.result()

BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

你见过类似的东西吗?对其他线程的引用或三个带参数的不同调用的示例对我来说就足够了。我也试过多处理但没有成功。

cx_Oracle 示例 Threads.py 显示 运行 不同线程中的两个语句:

. . .
def TheLongQuery():
     . . .

def DoALock():
    . . .


thread1 = threading.Thread(None, TheLongQuery)
thread1.start()

thread2 = threading.Thread(None, DoALock)
thread2.start()

thread1.join()
thread2.join()