小编use*_*280的帖子

多处理 - 执行外部命令并等待继续

我正在使用Linux.我有一个名为"combine"的外部可执行文件和一个20次迭代的循环.每次迭代时,需要使用依赖于第i次迭代的参数调用"combine".例:

arguments = " "

for i in range(1,20):
    arguments += str(i) + "_image.jpg "
    # begin of pseudo-code 
    execute: "./combine" + arguments  # in parallel using all cores

# pseudo-code continues
wait_for_all_previous_process_to_terminate
execute: "./merge_resized_images"  # use all cores - possible for one single command?
Run Code Online (Sandbox Code Playgroud)

如何使用Python中的多处理模块实现此目的?

python external-process multiprocessing

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

external-process ×1

multiprocessing ×1

python ×1