Skip to content

Commit

Permalink
add screenshot timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
PaleNeutron committed Jan 30, 2025
1 parent fcea7fb commit e9109b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions dataframe_image/_pandas_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ def generate_html(
html = obj.to_html(max_rows=max_rows, max_cols=max_cols, notebook=True)
# wrap html with a div and add id `dfi_table`
html = f'<div id="dfi_table">{html}</div>'
html_template = f"""<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta charset="UTF-8"/></head>{html}</html>"""
return html_template
return html


def save_image(img_str, filename):
Expand Down
3 changes: 2 additions & 1 deletion dataframe_image/converter/browser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def build_valid_html(self, html: str) -> str:

page = f"""
<!DOCTYPE html>
<html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8"/>
{css_str}
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions dataframe_image/converter/browser/playwright_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def screenshot(self, html):
)
pass
page.wait_for_timeout(200)
screenshot_bytes = locator.screenshot()
screenshot_bytes = locator.screenshot(timeout=1000)
im = Image.open(BytesIO(screenshot_bytes))
return im

Expand Down Expand Up @@ -168,6 +168,6 @@ async def screenshot(self, html):
)
pass
page.wait_for_timeout(200)
screenshot_bytes = await locator.screenshot()
screenshot_bytes = await locator.screenshot(timeout=1000)
im = Image.open(BytesIO(screenshot_bytes))
return im

0 comments on commit e9109b9

Please sign in to comment.