简体   繁体   English

Python:在继续循环之前等待进程完成?

[英]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: 我正在尝试使用PDFkit创建网站的PDF,但遇到了一些麻烦:

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. 在单个URL上运行pdfkit可以正常工作,但是尝试在for循环中使用它会导致问题。 I think it's because it takes a while for each PDF to be generated. 我认为这是因为生成每个PDF需要一段时间。

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? 有什么方法可以让我等待pdfkit运行,而只有在下一个URL与上一个URL结束时才继续处理?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在继续Python之前,等待子进程.exe完成 - Wait for subprocess .exe to finish before proceeding in Python 让Python等待函数完成后再继续执行程序 - Have Python wait for a function to finish before proceeding with the program 在下一个循环之前等待 Python 完成 - Wait for Python to finish before next loop 如何在 Python(和 Selenium)中的下一条语句之前等待 for 循环完成? - How to wait for the for loop to finish before next statement in Python (and Selenium)? 等待一个过程以Python脚本完成 - wait a process to finish in Python script Python 在 for 循环中的 os.system:如何在重新启动循环之前等待命令完成? - Python's os.system within a for loop: how to wait for a command to finish before re-starting the loop? python -c cmd将等待所有进程完成 - python -c cmd will wait all process finish 多处理 - 执行外部命令并等待继续 - multiprocessing - execute external command and wait before proceeding 使pygame在继续操作之前等待用户点击/输入(python问答游戏) - Making pygame wait for user click/input before proceeding (python quiz game) 了解python多重处理:代码是否等待所有过程完成 - Understanding python multiprocessing: does code wait for all process to finish
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM