2017-08-10 113 views
0

我有一个烧瓶网站。有时在某些请求上它返回此错误:烧瓶,SQLAlchemy错误(无效的事务)

Exception message: Can't reconnect until invalid transaction is rolled back (original cause: InvalidRequestError: Can't reconnect until invalid transaction is rolled back) u'SELECT a_auth2_user.id AS a_auth2_user_id, a_auth2_user.username AS a_auth2_user_username, a_auth2_user.fullname AS a_auth2_user_fullname, a_auth2_user.email AS a_auth2_user_email, a_auth2_user.password AS a_auth2_user_password, a_auth2_user.plain_password AS a_auth2_user_plain_password, a_auth2_user.legacy_password AS a_auth2_user_legacy_password, a_auth2_user.active AS a_auth2_user_active, a_auth2_user.is_admin AS a_auth2_user_is_admin, a_auth2_user.phone AS a_auth2_user_phone, a_auth2_user.last_activity AS a_auth2_user_last_activity \nFROM a_auth2_user \nWHERE a_auth2_user.id = %s \n LIMIT %s' [immutabledict({})]

奇怪的是,它返回此错误“有时”!有时它工作正常。 这是像内存问题?我该如何解决它?

回答

0

因为您之前的提交可能会有一些异常,所以如果有任何无效的事务,您应该将会话roolbak。

try: 
    transaction.commit() 
except Exception, e: 
    session.rollback()