Skip to content

Commit

Permalink
do NOT call get_config on module level
Browse files Browse the repository at this point in the history
  • Loading branch information
pedohorse committed Feb 3, 2025
1 parent 09f0570 commit 16ea942
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lifeblood/shared_lazy_sqlite_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ def _invoke_close_callbacks(self):


class ConnectionPool:
default_period = get_config('scheduler').get_option_noasync('shared_connection.keep_open_period', 0.0125)
get_logger('lazy_connection_pool').debug(f'using default open period: {default_period}')
default_period: Optional[float] = None

def __init__(self):
self.connection_cache: Dict[tuple, ConnectionPoolEntry] = {}
self.pool_lock = asyncio.Lock()
self.keep_open_period = self.default_period
self.__logger = get_logger('shared_aiosqlite_connection')
# TODO: should not be using get_config here, scheduler's data provider should be used instead
if ConnectionPool.default_period is None:
ConnectionPool.default_period = get_config('scheduler').get_option_noasync('shared_connection.keep_open_period', 0.0125)
self.__logger.debug(f'using default open period: {ConnectionPool.default_period}')
self.keep_open_period = ConnectionPool.default_period
self.__my_loop = asyncio.get_running_loop()

def is_in_this_loop(self, loop=None):
Expand Down

0 comments on commit 16ea942

Please sign in to comment.