X-Git-Url: http://dolda2000.com/gitweb/?p=didex.git;a=blobdiff_plain;f=didex%2Fdb.py;h=33eb0d8c7198b4b0a076a8b920fb58f14e4d523f;hp=316fa02f00804aa7bccdf79129b2f3354ffbb382;hb=d6d41a45b2882bf919cd7702d7590ead03e9d590;hpb=da5de0141d1328b254425b6a70d7a2c1f3c41c2b diff --git a/didex/db.py b/didex/db.py index 316fa02..33eb0d8 100644 --- a/didex/db.py +++ b/didex/db.py @@ -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):