diff options
Diffstat (limited to 'src/leap/soledad/client')
-rw-r--r-- | src/leap/soledad/client/_db/blobs.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/leap/soledad/client/_db/blobs.py b/src/leap/soledad/client/_db/blobs.py index 76746c71..05802dab 100644 --- a/src/leap/soledad/client/_db/blobs.py +++ b/src/leap/soledad/client/_db/blobs.py @@ -31,6 +31,7 @@ from functools import partial from twisted.logger import Logger from twisted.enterprise import adbapi from twisted.internet import defer +from twisted.internet import error import treq @@ -338,10 +339,21 @@ class BlobManager(object): for _ in range(min(self.concurrency_limit, len(docs_we_want))): blob_id = docs_we_want.pop() logger.info("Fetching new doc: %s" % blob_id) - deferreds.append(self.get(blob_id, namespace)) + d = self.__with_retry(self.get, blob_id, namespace) + deferreds.append(d) yield defer.gatherResults(deferreds) @defer.inlineCallbacks + def __with_retry(self, func, *args, **kwargs): + retries, max_retries = 0, 300 + while retries < max_retries: + try: + yield func(*args, **kwargs) + break + except(error.ConnectError, error.ConnectionClosed): + retries += 1 + + @defer.inlineCallbacks def sync(self, namespace=''): yield self.refresh_sync_status_from_server(namespace) yield self.fetch_missing(namespace) |