Roundup Tracker - Issues

Message5836

Author rouilj
Recipients ThomasAH, ber, ced, rouilj
Date 2016-07-11.23:40:55
Message-id <1468280456.09.0.156987515839.issue2550839@psf.upfronthosting.co.za>
In-reply-to
I am planning on committing the following patch:

     def _get_database(self):
         index = os.path.join(self.db_path, 'text-index')
-        return xapian.WritableDatabase(index, xapian.DB_CREATE_OR_OPEN)
+        for n in range(10):
+            try:
+                # if successful return
+                return xapian.WritableDatabase(index,
xapian.DB_CREATE_OR_OPEN)
+            except xapian.DatabaseLockError as e:
+                # adaptive sleep. Get longer as count increases.
+                time_to_sleep = 0.01 * (2 << min(5, n))
+                time.sleep(time_to_sleep)
+                # we are back to the for loop
+
+        # Get here only if we dropped out of the for loop.
+        raise xapian.DatabaseLockError("Unable to get lock after 10
retries on %s."%index)

basically on lock error retry 10 times and back off. If I fail
generate a DatabaseLockError.

Thoughts?

-- rouilj
History
Date User Action Args
2016-07-11 23:40:56rouiljsetmessageid: <1468280456.09.0.156987515839.issue2550839@psf.upfronthosting.co.za>
2016-07-11 23:40:56rouiljsetrecipients: + rouilj, ber, ThomasAH, ced
2016-07-11 23:40:55rouiljlinkissue2550839 messages
2016-07-11 23:40:55rouiljcreate