From 5e1446faa7f259c9c30321e0141a32e3aff129ff Mon Sep 17 00:00:00 2001 From: Lee Chapman Date: Sun, 8 Feb 2026 23:01:56 -0800 Subject: [PATCH] fix: make connection pool size configurable via POOL_MAX_CONN env Poller exhausts 50-connection pool during burst (264 planets + 44 campaigns). Allows poller to use larger pool (e.g. 100) without affecting API defaults. Co-authored-by: Cursor --- src/database.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/database.py b/src/database.py index 4db5264..11e8728 100644 --- a/src/database.py +++ b/src/database.py @@ -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")