Permalink
Browse files

Added storeRetryUpdate.

  • Loading branch information...
1 parent 16ca699 commit 2f7f4b860b853a6aa515a93200bfea45b582c74d Eli Stevens committed Mar 7, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 couchable/core.py
View
@@ -316,6 +316,16 @@ def __deepcopy__(self, memo):
# inst = cls.__new__(cls)
# inst.__dict__.update({copy.deepcopy(k): copy.deepcopy(v) for k,v in self.__dict__.items if k not in ['_cdb']})
+ def storeRetryUpdate(self, update_func, what, skip=None, additiveOnly=False):
+ while True:
+ try:
+ update_func(what)
+
+ return self.store(what, skip, additiveOnly)
+ except couchdb.http.ResourceConflict:
+ time.sleep(random.random())
+
+ what = self.load(what)
def store(self, what, skip=None, additiveOnly=False):
"""

0 comments on commit 2f7f4b8

Please sign in to comment.