jkklee / pymysql-pool

A simple but robust connection pool (with multiplexing) base on PyMySQL, mainly used for multi threads mode, which also compatible with single thread mode.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pymysql.err.OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")

strongit opened this issue · comments

好像还是没解决session超时重连的问题,超过8个小时,还是会用之前的session

先问一句题外话,你用的哪个版本的pymysql

mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
版本不对吗

这个异常是需要你的代码去捕捉的。连接池只保证你能正常的从池中获取链接,把“仍然可用的链接”放回连接池。但从你返回了一个“可用的链接”至连接池,到你下一次从池中取出这个链接的这段时间内,不保证这期间链接不会被mysql主动kill掉,以及客户端和mysql服务器之间种种原因导致该链接被重置等导致该链接不可用的情况。
你说的这种情况如果要解决的话,就得在连接池提链接之前对该链接进行“可用性测试”,但是这个从性能上讲,有点得不偿失。

谢谢反馈

@strongitb7e012b 中新增了一个可选的预先检查机制,默认关闭。
包含在最新版本(0.3.5)中。