summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/orm/models.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 3c51c6f798..0d598aca19 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -29,10 +29,28 @@ from django.core import validators
29from django.conf import settings 29from django.conf import settings
30import django.db.models.signals 30import django.db.models.signals
31 31
32
33import logging 32import logging
34logger = logging.getLogger("toaster") 33logger = logging.getLogger("toaster")
35 34
35if 'sqlite' in settings.DATABASES['default']['ENGINE']:
36 from django.db import transaction, OperationalError
37 from time import sleep
38
39 _base_save = models.Model.save
40 def save(self, *args, **kwargs):
41 while True:
42 try:
43 with transaction.atomic():
44 return _base_save(self, *args, **kwargs)
45 except OperationalError as err:
46 if 'database is locked' in str(err):
47 logger.warning("%s, model: %s, args: %s, kwargs: %s",
48 err, self.__class__, args, kwargs)
49 sleep(0.5)
50 continue
51 raise
52
53 models.Model.save = save
36 54
37class GitURLValidator(validators.URLValidator): 55class GitURLValidator(validators.URLValidator):
38 import re 56 import re