Skip to content

Commit

Permalink
Do not specify a reconnect argument to mysql ping() if on mysql 8.
Browse files Browse the repository at this point in the history
Replaces #2835
  • Loading branch information
coleifer committed Feb 5, 2024
1 parent 5e42c67 commit dff8fbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -4227,8 +4227,12 @@ def is_connection_usable(self):

conn = self._state.conn
if hasattr(conn, 'ping'):
if self.server_version[0] == 8:
args = ()
else:
args = (False,)
try:
conn.ping(False)
conn.ping(*args)
except Exception:
return False
return True
Expand Down
6 changes: 5 additions & 1 deletion playhouse/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ def close_all(self):

class PooledMySQLDatabase(PooledDatabase, MySQLDatabase):
def _is_closed(self, conn):
if self.server_version[0] == 8:
args = ()
else:
args = (False,)
try:
conn.ping(False)
conn.ping(*args)
except:
return True
else:
Expand Down

0 comments on commit dff8fbc

Please sign in to comment.