Not able to parallel execute linux command in python using subprocess?

Viewed 45

I have two files in my present working directory,

cwd:
    0.docx
    1.docx

from multiprocessing.dummy import Pool
import subprocess

def convert_to(source):
    args = [
        "soffice",
        "--headless",
        "--convert-to",
        "pdf:writer_pdf_Export",
        source,
    ]
    process = subprocess.Popen(
        args,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=False,
    )
    return process.communicate()

pool = Pool()
print(pool.map(convert_to, ["0.docx", "1.docx"]))

Now, after executing the above code If I check my current working directory,

Here are the files I see,

cwd:
    0.docx
    1.docx
    1.pdf

Its only converting one file (i.e., docx to pdf) but the code is suppose to be executing both at once and convert both the files.

Please help out.

0 Answers
Related