Python: Pyppeteer with asyncio

£可爱£侵袭症+ 提交于 2019-12-06 06:39:47

According to pyppeteer source code, it is using subprocess without pipes to manage Chromium processes, and websockets to communicate, therefore it is async.

You have 31 sites, then you'll have 31+1 processes. So unless you have a CPU with 32 cores (there might also be threads, system processes, locks, hyper-threading and all different factors infecting the result, so this is just an imprecise example), it won't be fully executed in parallel. Therefore, the bottleneck I think is CPU opening browsers, rendering web pages and dumping into images. Using executor won't help.

However, it is still async. That means, your Python process is not blocked, you can still run other code or wait for network results concurrently. It is only that when the CPU is fully loaded by other processes, it becomes harder for the Python process to "steal" CPU time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!