我们有一个运行 uwsgi、nginx 的 python 应用程序。
我们有一个数据库的回退机制。即,如果一台服务器拒绝连接,我们将连接到另一台服务器。但问题是连接超时时间超过 60 秒。
nginx 60s超时,显示nginx错误页面。我们在哪里可以更改连接到 mysql 服务器的超时时间,以便我们可以在给定的 60 秒 nginx 超时期限内尝试连接 mysql 三次?
我们使用 Web2py 和带有 pymysql 适配器的默认 DAL 对象
最佳答案
你是在谈论选项connect_timeout
?
conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='', db='mysql', connect_timeout=20)
在 DAL 术语中,此选项将与此有关(未测试)
db = DAL('mysql://username:password@localhost/test', driver_args={connect_timeout=20})
关于python - 如何减少我的 python 应用程序连接到 mysql 服务器的超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16026968/