I have a shell script that uses GNU Parallel to run function in parallel. Now, I am rewriting the script to Python and I dont know, how to do this correctly.
In script, I have:
parallel --jobs 5 --linebuffer run {1} ::: "${files[@]}"
How can I convert this to Python code? In shell, files
is an array of files, run
method calls external program that process the file.
In Python, I have method def run(file)
, that have several Python command to prepare data and at the end, it calls external program with os.command
.
def run(file):
do something with input file
os.command(...)