(doc, update_fn, max_tries=5)
A function for safely applying a change to a couch doc. For getting around ResourceConflict
    errors that stem from the distributed cloudant nodes
A function for safely applying a change to a couch doc. For getting around ResourceConflict
    errors that stem from the distributed cloudant nodes
A function for safely applying a change to a couch doc . For getting around ResourceConflict errors that stem from the distributed cloudant nodes
def apply_update(doc, update_fn, max_tries=5):
    """
    A function for safely applying a change to a couch doc. For getting around ResourceConflict
    errors that stem from the distributed cloudant nodes
    """
    tries = 0
    while tries < max_tries:
        try:
            update_fn(doc)
            doc.save()
            return doc
        except ResourceConflict:
            doc = doc.__class__.get(doc._id)
        tries += 1
    raise ResourceConflict("Document update conflict. -- Max Retries Reached")
def apply_update ( doc , update_fn , max_tries = 5 ) : tries = 0 while tries < max_tries : try : update_fn ( doc ) doc . save ( ) return doc except ResourceConflict : doc = doc . __class__ . get ( doc . _id ) tries += 1 raise ResourceConflict ( "Document update conflict. -- Max Retries Reached" )