Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImgKit takes a long time to convert an html file to a jpg file (3 minutes) #56

Open
MahdeenSky opened this issue Mar 10, 2021 · 5 comments

Comments

@MahdeenSky
Copy link

imgkit.from_file(html_filename, image_filename, options={"width": 660, "disable-smart-width": ""})
is what I ran, and for some reason, at most times, this will take 3 minutes to run, and just yesterday, and only for yesterday, was it running at around 3 to 10 secs. The html, I am trying to render, is not important to mention, as the same problem happens with "www.google.com", about 3 minutes as well. I am running on Ubuntu 20.04.

Extra Detail:
for most of the time, there is no output in the console, and only in the last few seconds, the output appears

Loading page (1/2)
Rendering (2/2)                                                    
Done                                                               
@MahdeenSky
Copy link
Author

When i keyboard interrupt in the middle, the function appears to be stuck within what appears to be a timeout.

^CTraceback (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)

@jarrekk
Copy link
Owner

jarrekk commented Mar 13, 2021

How about the time duration for other sites?

@trae-horton
Copy link

So I just opened a new issue and it might be related to this:

#77

The conversation finally completed but I have no idea how long it took due to leaving it over night. I attached the .html to issue 77. I think if we had a timeout flag for embedded URLs in the HTML may fix our issues but idk.

@trae-horton
Copy link

Okay so I found my issue. It ended up being an IPS doing TCP-DROP instead of TCP-REST. In my opinion a flag to declare a timeout for specific TCP connection would be a good idea to prevent slow servers failing to respond to hold up the code. I would imagine that this would be a pretty big feature request though. Going to close out #77

@dreamerhyde
Copy link

Any updates? I got the same issues..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants