diff --git a/pymysqlpool/pool.py b/pymysqlpool/pool.py index b511de9..fab4a1e 100644 --- a/pymysqlpool/pool.py +++ b/pymysqlpool/pool.py @@ -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", @@ -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 @@ -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, @@ -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):