The first thing to make sure of is that you set the ‘pool_recycle
option’ when using SQLAlchemy ‘create_engine’ function (more here).
The value of pool_recycle should be less than your MYSQLs wait_timeout
value (both are in seconds).
The next and altogether knottier problem is to make sure you correctly
manage your session life cycle. It’s well worth carefully reading this
documentation. Essentially, you have to make sure that your session is
correctly opened when your data request starts and closed when it’s
done.
SQLAlchemy的引擎都被实现为池,即使它们实际上不是池。在
请先于你读过这篇文章的人:SQLAlchemy – MYSQL has gone away。简而言之:
相关问题 更多 >
编程相关推荐