Make generate_backups function atomic, increase DB timeout

This commit is contained in:
Tanner Collin 2020-11-24 23:00:45 +00:00
parent 6a6fa7d504
commit a7051f80ac
2 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.utils.timezone import now
from django.core.cache import cache
from django.db import transaction
from apiserver import secrets, settings
from apiserver.api import models
@ -25,6 +26,7 @@ backup_id_string = lambda x: '{}\t{}\t{}'.format(
class Command(BaseCommand):
help = 'Generate backups.'
@transaction.atomic
def generate_backups(self):
backup_users = secrets.BACKUP_TOKENS.values()

View File

@ -116,6 +116,9 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'data/db.sqlite3'),
'OPTIONS': {
'timeout': 20, # increased because generate_backups.py blocks
},
},
'old_portal': {
'ENGINE': 'django.db.backends.sqlite3',