Fixed some index bugs.
[didex.git] / didex / db.py
index 316fa02..33eb0d8 100644 (file)
@@ -2,6 +2,8 @@ import time, threading, struct
 from . import lib
 from bsddb3 import db as bd
 
+__all__ = ["environment", "database"]
+
 deadlock = bd.DBLockDeadlockError
 
 class environment(lib.closable):
@@ -92,6 +94,15 @@ class txn(object):
     def postcommit(self, fun):
         self.pcommit.add(fun)
 
+def dloopfun(fun):
+    def wrapper(self, *args, **kwargs):
+        while True:
+            try:
+                return fun(self, *args, **kwargs)
+            except deadlock:
+                continue
+    return wrapper
+
 def txnfun(envfun):
     def fxf(fun):
         def wrapper(self, *args, tx=None, **kwargs):