Skip to content

Commit 3e98bb6

Browse files
committed
Optimize db for multiple readers
1 parent 2f106c9 commit 3e98bb6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

tests/json_infra/helpers/fixture_db.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,17 @@ def __init__(self, db_path: str = "tests/json_infra/fixtures.db"):
362362
def connect(self) -> sqlite3.Connection:
363363
"""Connect to database."""
364364
if self.conn is None:
365-
self.conn = sqlite3.connect(self.db_path, check_same_thread=False)
365+
self.conn = sqlite3.connect(
366+
self.db_path,
367+
check_same_thread=False,
368+
timeout=30.0, # 30 second timeout for locks
369+
uri=True,
370+
)
366371
self.conn.row_factory = sqlite3.Row
372+
# Read-only optimizations for concurrent access
373+
self.conn.execute("PRAGMA query_only=1")
374+
self.conn.execute("PRAGMA temp_store=MEMORY")
375+
self.conn.execute("PRAGMA cache_size=-64000") # 64MB cache
367376
return self.conn
368377

369378
def fetch_state_tests(self, fork: str) -> Generator[Dict, None, None]:

tox.ini

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ commands =
5959
--basetemp="{temp_dir}/pytest" \
6060
src
6161

62-
[testenv:build_fixture_db]
63-
description = Build the JSON fixture database
64-
commands =
65-
python -m tests.json_infra.build_fixture_db
66-
6762
[testenv:json_infra]
6863
description = Run the spec against released test fixtures
6964
passenv =

0 commit comments

Comments
 (0)