← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-1154467-2.0 into lp:openlp/2.0

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-1154467-2.0 into lp:openlp/2.0.

Requested reviews:
  Tim Bentley (trb143)
  Phill (phill-ridout)
  Andreas Preikschat (googol)
Related bugs:
  Bug #1154467 in OpenLP: "Web download bible db's getting locked"
  https://bugs.launchpad.net/openlp/+bug/1154467

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-1154467-2.0/+merge/200137

Attempt to fix bug #1154467 by waiting 10ms and retrying the commit
-- 
https://code.launchpad.net/~raoul-snyman/openlp/bug-1154467-2.0/+merge/200137
Your team OpenLP Core is subscribed to branch lp:openlp/2.0.
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py	2013-12-21 23:26:36 +0000
+++ openlp/plugins/bibles/lib/db.py	2013-12-28 22:21:49 +0000
@@ -32,9 +32,11 @@
 import os
 import re
 import sqlite3
+import time
 
 from PyQt4 import QtCore
 from sqlalchemy import Column, ForeignKey, or_, Table, types, func
+from sqlalchemy.exc import OperationalError
 from sqlalchemy.orm import class_mapper, mapper, relation
 from sqlalchemy.orm.exc import UnmappedClassError
 
@@ -48,6 +50,7 @@
 
 RESERVED_CHARACTERS = u'\\.^$*+?{}[]()'
 
+
 class BibleMeta(BaseModel):
     """
     Bible Meta Data
@@ -257,7 +260,12 @@
                 text=verse_text
             )
             self.session.add(verse)
-        self.session.commit()
+        try:
+            self.session.commit()
+        except OperationalError:
+            # Wait 10ms and try again.
+            time.sleep(0.01)
+            self.session.commit()
 
     def create_verse(self, book_id, chapter, verse, text):
         """
@@ -363,7 +371,7 @@
 
         ``book``
             The name of the book, according to the selected language.
-        
+
         ``language_selection``
             The language selection the user has chosen in the settings
             section of the Bible.


Follow ups