You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

wfastcgi环境下Flask应用调用df.plot时触发500错误求助

FastCgiModule引发异常,仅调用pandas df.plot时触发(Flask部署在IIS)
  • 最初排查认为是IIS问题,现在确认是FastCgiModule引发的异常
  • WebApp本身可正常运行,仅当选择站点下拉菜单中的「Image Test」选项时请求失败,错误明确触发在df.plot()代码行,目前无法定位根因

相关代码

from flask import Flask, request
import pandas as pd

app = Flask(__name__)

html = '''
<h1>Discovery Capital</h1>
<h2>Report Generator</h2>
<p>
<form action="/submitted" method="post">
  <label for="reports">Choose a Report:</label>
  <select id="reports" name="reports">
    <option value="img_test">Image Test</option>
  </select>
  <input type="submit">
</form>
'''

@app.route("/")
def index():
    return html

@app.route("/submitted", methods=['POST'])
def show():
    select = request.form.get("reports")

    if select == 'img_test':
        df = pd.DataFrame([1,2,3,4,5])
        df.plot()
        plt.close()
        result = "Success"

    else:
        result = "Not Available"

    return result

if __name__ == "__main__":
    app.run()

备注:代码中使用plt.close()但未导入matplotlib.pyplot,这是一处明显的代码缺陷,但当前请求失败由FastCgiModule异常引发,需优先排查该模块相关问题

补充信息

失败请求跟踪日志显示:FastCgiModule在处理请求时抛出异常,核心提示为FastCGI进程意外终止,导致请求处理失败。

恳请各位提供排查思路或解决方案!

内容的提问来源于stack exchange,提问作者David Yang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 19:10:32