summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-12-09 19:56:40 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-14 23:13:07 +0000
commit507aafbd7ac90b4dfbe0f070e8180368012dc1f5 (patch)
tree81282cdc990ab16beb08f89ed9e4e8fbe3051c84 /bitbake/lib/toaster
parent322b4709d84dadb6d34612781f1fdf0ebad7faa8 (diff)
downloadpoky-507aafbd7ac90b4dfbe0f070e8180368012dc1f5.tar.gz
bitbake: toaster: work around 'database is locked' error
When sqlite can not cope with a stream of 'insert' queries it throws 'database is locked' exception. Wrapping model.save in transaction.atomic context and repeating the call should solve this issue. (Bitbake rev: eb305308ca8f6228c6f52dac1bd941f29c7e5eb6) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-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