Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ def __init__(self, database_url: Optional[str] = None):
def _get_pool(self) -> pool.ThreadedConnectionPool:
"""Get or create the connection pool (lazy init)"""
if self._pool is None:
import os
maxconn = DEFAULT_POOL_MAX_CONN
if (env_max := os.getenv("POOL_MAX_CONN")) is not None:
try:
maxconn = int(env_max)
except ValueError:
pass
self._pool = pool.ThreadedConnectionPool(
minconn=DEFAULT_POOL_MIN_CONN,
maxconn=DEFAULT_POOL_MAX_CONN,
maxconn=maxconn,
dsn=self.database_url,
)
logger.info("Database connection pool initialized")
Expand Down