Skip to content

Commit

Permalink
Merge pull request #1 from seunggabi/feature/#19_singleton
Browse files Browse the repository at this point in the history
(jkklee#19) feat: singleton
  • Loading branch information
seunggabi committed Aug 16, 2023
2 parents cfa69f8 + ca431be commit 8452270
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ eggs
.idea
test.py
*.swp

venv
15 changes: 15 additions & 0 deletions pymysqlpool_singleton.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pymysqlpool import ConnectionPool


class ConnectionPoolSingleton:
_instance = None

def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = cls._create_pool(*args, **kwargs)

return cls._instance

@staticmethod
def _create_pool(*args, **kwargs):
return ConnectionPool(*args, **kwargs)

0 comments on commit 8452270

Please sign in to comment.