首页 > 解决方案 > Flask 应用程序随机抛出内部服务器错误

问题描述

我已经设置了一个烧瓶应用程序,它从我的 Postgres 获取数据(使用 psycopg2)并在点击相关 URL 时以 JSON 格式返回它。它在大多数情况下都能正常工作,但在随机执行次数后它会返回:

**Internal Server Error**

The server has encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

该应用程序托管在 EC2 t2.micro 中,而 Postgres 是 AWS RDS。任何想法将不胜感激。

更新

在 EC2 日志中,我看到了以下 Psycopg2 错误

 psycopg2.InternalError: current transaction is aborted, commands ignored until end of transaction block

查询中似乎有错误,但不应该是因为它在大多数情况下都能正常运行。

标签: pythonflaskamazon-ec2psycopg2

解决方案


推荐阅读