Skip to content

Commit 22280af

Browse files
committed
Cache in-memory databases
1 parent be9a434 commit 22280af

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tiled/server/connection_pool.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ async def __aexit__(self, *excinfo):
5757
def open_database_connection_pool(database_settings: DatabaseSettings) -> AsyncEngine:
5858
if make_url(database_settings.uri).database == ":memory:" or database_settings.uri == "sqlite://":
5959
# For SQLite databases that exist only in process memory,
60-
# pooling is not applicable. Just return an engine and don't cache it.
6160
engine = create_async_engine(
6261
ensure_specified_sql_driver(database_settings.uri),
6362
echo=DEFAULT_ECHO,
@@ -77,9 +76,9 @@ def open_database_connection_pool(database_settings: DatabaseSettings) -> AsyncE
7776
pool_pre_ping=database_settings.pool_pre_ping,
7877
)
7978

80-
# Cache the engine so we don't create more than one pool per database_settings.
81-
monitor_db_pool(engine.pool, sanitize_uri(database_settings.uri)[0])
82-
_connection_pools[database_settings] = engine
79+
# Cache the engine so we don't create more than one pool per database_settings.
80+
monitor_db_pool(engine.pool, sanitize_uri(database_settings.uri)[0])
81+
_connection_pools[database_settings] = engine
8382

8483
# For SQLite, ensure that foreign key constraints are enforced.
8584
if engine.dialect.name == "sqlite":

0 commit comments

Comments
 (0)