Make generate_backups function atomic, increase DB timeout
This commit is contained in:
parent
6a6fa7d504
commit
a7051f80ac
|
@ -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()
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue
Block a user