Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions pymysqlpool/pool.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,7 @@ def __init__(self,
host="localhost",
port=3306,
user=None,
password=None,
password: str | None = None,
unix_socket=None,
db=None,
charset="utf8",
Expand All@@ -78,7 +78,7 @@ def __init__(self,
multiple=4,
counter=0,
accumulation=0,
ping_check: (int, bool) = False,
ping_check: int | bool = False,
**configs):
self.host = host
self.port = port
Expand DownExpand Up@@ -115,7 +115,7 @@ def create_conn(self):
host=self.host,
port=self.port,
user=self.user,
password=self.password,
password=self.password or "",
db=self.db,
charset=self.charset,
cursorclass=self.cursorclass,
Expand DownExpand Up@@ -182,10 +182,12 @@ def __get_safe_conn(self, retry_count):
if c.__ping_check_timestamp < timeout:
c.__ping_check_timestamp = now
c.ping()
except:
except Exception:
self.current_size -= 1
if retry_count < 10: c = self.__get_conn(retry_count+1)
if c: self.inuse_list.add(c)
if retry_count < 10:
c = self.__get_conn(retry_count+1)
if c:
self.inuse_list.add(c)
return c

def get_pool_size(self):
Expand Down