Skip to main content
 首页 » 编程设计

python之由于 Pandas 崩溃, flask 服务器退出而没有任何消息

2024年10月25日10yyy_WW

我不知道为什么服务器在一个 http 请求后没有任何错误信息就崩溃了。

如何让它显示异常,谢谢

网络.py

if __name__ == "__main__": 
    app.run(debug=True, host='0.0.0.0', port=APP_CFG["server_port"]) 
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 

控制台日志

 * Running on http://0.0.0.0:8005/ (Press CTRL+C to quit) 
 * Restarting with stat 
218.174.206.147 - - [17/Apr/2015 09:14:36] "GET /materials?table_name=1&measure=actual%2Cupper_end_of_central_tendency HTTP/1.1" 200 - 
218.174.206.147 - - [17/Apr/2015 09:14:37] "GET /favicon.ico HTTP/1.1" 200 - 
218.174.206.147 - - [17/Apr/2015 09:14:37] "GET /favicon.ico HTTP/1.1" 200 - 

pip 包版本

argh (0.26.1) 
command-not-found (0.3) 
Flask (0.10.1) 
itsdangerous (0.24) 
Jinja2 (2.7.3) 
language-selector (0.1) 
MarkupSafe (0.23) 
numpy (1.9.1) 
pandas (0.15.2) 
pathtools (0.1.2) 
pip (6.0.8) 
pycurl (7.19.3) 
pygobject (3.12.0) 
python-apt (0.9.3.5) 
python-dateutil (2.4.0) 
pytz (2014.10) 
PyYAML (3.11) 
setuptools (12.1) 
six (1.9.0) 
ufw (0.34-rc-0ubuntu2) 
unattended-upgrades (0.1) 
watchdog (0.8.3) 
Werkzeug (0.10.1)    

我发现 buggy 部分是 Pandas bug。

如果我尝试在空数据帧上调用 to_json()。

进程将在没有任何消息的情况下退出。

Empty DataFrame 
Columns: [2012, 2013, 2014, 2015, 2016, schedule_id, measures] 
Index: [] 
(Pdb) rr.to_json() 

请您参考如下方法:

这是 0.16.0 中的一个错误,已在 master 中修复(将在 0.16.1 中发布,四月底)。参见 here