当我有时运行aiohttp基本服务器并使其闲置时,我得到了MySQL服务器已消失的错误,
我的数据库连接如下
async def init_db(app):
conf = app["config"]["mysql"]
engine = create_engine(
f"mysql+mysqlconnector://{conf['user']}:{conf['password']}@{conf['host']}:"
f"{conf['port']}/{conf['database']}", pool_pre_ping=True, pool_recycle=3600
)
app["db_session"] = sessionmaker(bind=engine)
def create_app():
app = web.Application()
app["config"] = config
add_routes(app)
app.on_startup.append(init_db)
return app
增加mysql的池大小不起作用,而Im使用sqlalchemy 这与异步特性有关吗?或对此有解决方法?