imgkit.from_file(html_filename, image_filename, options={"width": 660, "disable-smart-width": ""})
是我跑的,出于某种原因,在大多数情况下,这需要 3 分钟才能运行,而就在昨天,而且仅在昨天,它的运行时间大约是 3 到 10 秒。我试图渲染的 html 并不重要,因为“www.google.com”也会出现同样的问题,大约需要 3 分钟。我在 Ubuntu 20.04 上运行。
额外细节: 大部分时间,控制台没有输出,只有在最后几秒钟,才会出现输出
Loading page (1/2)
Rendering (2/2)
Done
当我在中间中断键盘时,该功能似乎卡在了似乎是超时的范围内。
Traceback (most recent call last):
File "test.py", line 11, in <module>
html_to_image("result.html", "result.jpg")
File "test.py", line 6, in html_to_image
imgkit.from_file(html_filename, image_filename, options={"width": 660, "disable-smart-width": ""})
File "/home/smi/.local/lib/python3.8/site-packages/imgkit/api.py", line 64, in from_file
return rtn.to_img(output_path)
File "/home/smi/.local/lib/python3.8/site-packages/imgkit/imgkit.py", line 225, in to_img
stdout, stderr = result.communicate(input=string)
File "/usr/local/lib/python3.8/subprocess.py", line 1024, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/local/lib/python3.8/subprocess.py", line 1866, in _communicate
ready = selector.select(timeout)
File "/usr/local/lib/python3.8/selectors.py", line 415, in select
fd_event_list = self._selector.poll(timeout)
如果有人能伸出援手,将不胜感激!