diff options
-rw-r--r-- | gdatastore/index.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gdatastore/index.py b/gdatastore/index.py index c93f5b3..35491bf 100644 --- a/gdatastore/index.py +++ b/gdatastore/index.py @@ -19,6 +19,7 @@ Gdatastore metadata index interface import logging import os import sys +import time import xapian from xapian import Document, Enquire, Query, WritableDatabase @@ -320,8 +321,17 @@ class Index(object): database.close() def _migrate(self): - self._database = WritableDatabase(self._base_dir, - xapian.DB_CREATE_OR_OPEN) + for try_count in range(10): + try: + self._database = WritableDatabase(self._base_dir, + xapian.DB_CREATE_OR_OPEN) + except xapian.DatabaseLockError: + logging.error("Couldn't lock Xapian database (try #%d)", + try_count) + time.sleep(1) + else: + break + version = int(self._database.get_metadata('gdatastore_version')) if version > _CURRENT_VERSION: |