no classification
no tag
no datas
posted on 2024-12-02 22:10 read(869) comment(0) like(2) collect(3)
While using Flask-SQLAlchemy I get the error 'QueuePool limit of size 10 overflow 10 reached, connection timed out' consistently, after some time. I tried to increase connection pool size, but it only deferred the problem.
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
initialize_db(app)
db = SQLAlchemy()
def initialize_db(app):
db.init_app(app)
SQLALCHEMY_POOL_SIZE = 100
I figured out the problem. The issue was sometimes database connection was going to lost state, which is causing pool size to be Exhausted after some interval.
To fix the issue I made the MySQL server configuration change for query timeout and made it 1 second.
After 1 second if the query didn't respond it will throw Exception and I added except block in code where that query was invoked(In my case it was GET query). In the Except block, I issued rollback command.
Author:qs
link:http://www.pythonblackhole.com/blog/article/247241/51a886bbbe0604011ec8/
source:python black hole net
Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!