【发布时间】:2022-05-10 20:33:35
【问题描述】:
我正在寻找一种方法,或者可能是一种哲学方法,以了解如何在 python 中执行 GNU Make 之类的操作。目前,我们使用 makefile 来执行处理,因为 makefile 非常擅长并行运行,只需更改单个选项:-j x。此外,gnu make 已经内置了依赖堆栈,因此添加辅助处理器或处理更多线程的能力仅意味着更新该单个选项。我希望在 python 中具有同样的功能和灵活性,但我没有看到。
举个例子:
all: dependency_a dependency_b dependency_c
dependency_a: dependency_d
stuff
dependency_b: dependency_d
stuff
dependency_c: dependency_e
stuff
dependency_d: dependency_f
stuff
dependency_e:
stuff
dependency_f:
stuff
如果我们做一个标准的单线程操作(-j 1),那么操作的顺序可能是:
dependency_f -> dependency_d -> dependency_a -> dependency_b -> dependency_e \
-> dependency_c
对于两个线程(-j 2),我们可能会看到:
1: dependency_f -> dependency_d -> dependency_a -> dependency_b
2: dependency_e -> dependency_c
是否有人对已构建的软件包或方法有任何建议?我完全开放,只要它是一个 pythonic 解决方案/方法。
请提前致谢!
【问题讨论】:
-
2022,还有一些还在寻找这个
标签: python concurrency dependencies makefile parallel-processing