Coverage for sm/signals.py: 60%

10 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-10-24 19:06 +0000

1from django.db.backends.signals import connection_created 

2from django.dispatch import receiver 

3 

4 

5@receiver(connection_created) 

6def set_sqlite_pragmas(sender, connection, **kwargs): 

7 """ 

8 Harden SQLite connections against concurrent access (live server threads 

9 + test runner). WAL mode allows concurrent readers/writers, and a busy 

10 timeout makes writers wait instead of failing with "database is locked". 

11 """ 

12 if connection.vendor != "sqlite": 

13 return 

14 with connection.cursor() as cursor: 

15 cursor.execute("PRAGMA journal_mode=WAL;") 

16 cursor.execute("PRAGMA busy_timeout=30000;") 

17 cursor.execute("PRAGMA synchronous=NORMAL;")