pio.write_image not working from within flask route

オープン
#238 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

提供されている関数 saveScreenshot_2 から始め、Windows 10 上で Flask の route の内外で pio.write_image を再現します。Plotly 5.24.1 と Kaleido 0.2.1 を使用して動作を比較し、その後、ハングが route のコンテキストで発生しているのか、画像エクスポート呼び出しで発生しているのかを特定します。原因が特定され、検証済みの修正または明確な再現手順が文書化されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

I am having an issue trying to store plotly image with command:
img = pio.write_image(fig=fig, file=fileName, format="png", width=800, height=500, scale=1, engine="kaleido")
It just hangs forever and cannot do anything.

I honestly do not know if this is plotly or kaleido issue. Funny thing is this only happens when within the Flask route. Same code works fine outside the route. For example, if I run this code:

def saveScreenshot_2(fig, width=800, height=500):
    ic("def saveScreenShot_2")
    """Saves a Plotly figure as an image to a temporary file.

    Args:
        fig: The Plotly figure object.
        width: The width of the image in pixels (default: 800).
        height: The height of the image in pixels (default: 500).

    Returns:
        The path to the saved image file.
    """
    with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file:
        try:
            pio.write_image(fig=fig, format="png", file=temp_file.name, width=width, height=height, engine="kaleido")
            ic("after pio.write_image")
            return temp_file.name
        except Exception as e:
            print(f"Error saving image: {e}")
            return None

outside the flask route, it works normally, but within flask route, it just hangs:
windows 10,
plotly.version: '5.24.1', kaleido.version: '0.2.1'

主要言語
Python
スター
504
フォーク
65
平均マージ
6日 9時間
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/kaleido のほかの issue

plotly/kaleido の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。