简体   繁体   中英

Python: Wait for process to finish before proceeding in loop?

I'm attempting to use PDFkit to create PDFs of a site and I'm having some trouble:

for u in urls:
    for c in u.children:
        pdfkit.from_url(c, "test.pdf", configuration=config)

Running pdfkit on a single URL works fine, but trying to use it in a for loop causes problems. I think it's because it takes a while for each PDF to be generated.

Is there a way I could wait while pdfkit is running, and only proceed with the next URL when it has finished with the previous?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM