Commit 48deead9 authored by Michael Salim's avatar Michael Salim
Browse files

Workaround for DB lock OperationalError with sqlite3 backend.

An mpi4py test program with the Python sqlite3 wrapper has no trouble
with concurrent DB insertions from several tens of processes.  The issue
appears to be in the Django-sqlite3 wrapper.

This patch simply wraps save() in a loop that intercepts
OperationalError until the save is successful.
parent 492d5eab
......@@ -9,6 +9,7 @@ import uuid
from django.core.exceptions import ValidationError,ObjectDoesNotExist
from django.conf import settings
from django.db import models
from django.db.utils import OperationalError
from concurrency.fields import IntegerVersionField
from concurrency.exceptions import RecordModifiedError
......@@ -249,7 +250,12 @@ class BalsamJob(models.Model):
if self._state.adding:
update_fields = None, force_insert, force_update, using, update_fields)
# Work around sqlite3 DB locked error
while True:
try:, force_insert, force_update, using, update_fields)
except OperationalError: pass
else: break
def __str__(self):
return f'''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment