Skip to content

Some minor tweaks #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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 number Diff line number Diff 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 Down Expand 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 Down Expand 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