20 lines
699 B
Python
20 lines
699 B
Python
"""سیگنالهای اپ admin_panel."""
|
|
import logging
|
|
|
|
from django.db.backends.signals import connection_created
|
|
from django.dispatch import receiver
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@receiver(connection_created)
|
|
def configure_sqlite_connection(sender, connection, **kwargs):
|
|
"""افزایش busy_timeout برای SQLite تا نوشتن همزمان web/worker/scheduler خطا ندهد."""
|
|
if connection.vendor != "sqlite":
|
|
return
|
|
try:
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("PRAGMA busy_timeout=30000;")
|
|
except Exception:
|
|
logger.warning("تنظیم busy_timeout برای SQLite ناموفق بود.", exc_info=True)
|