【发布时间】:2012-12-13 11:49:15
【问题描述】:
通过 gunicorn 运行 django 到 RDS (AWS mysql),我在 gunicorn 日志中看到此错误:
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x690ecd0>> ignored
我还不能可靠地重现它,也无法追踪导致它的底层代码。
我在某些地方使用原始光标,遵循以下模式:
cursor = connections['read_only'].cursor()
sql = "select username from auth_user;"
cursor.execute(sql)
rows = cursor.fetchall()
usernames = []
for row in rows:
usernames.append(row[0])
在某些地方,我会立即将游标重用于另一个查询 execute() / fetchall() 模式。有时我不会。
我还在某些地方使用原始管理器查询。
我没有明确关闭游标,但我认为我不应该这样做。
除此之外:我没有使用任何存储过程,没有 init_command 参数,也没有在我在这里看到的其他答案中指出任何其他内容。
任何关于如何调试的想法或建议都将不胜感激。
【问题讨论】:
-
除了显示在日志中之外,此异常是否会给您带来任何实际问题?
标签: mysql django mysql-python amazon-rds