From fc40f5525a987033cf40c9fb21092b0a217d2b2e Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Wed, 21 Jun 2017 11:45:38 -0400 Subject: [PATCH] add download_sd_blob timeout to GetStream --- lbrynet/core/client/StandaloneBlobDownloader.py | 4 ++-- lbrynet/daemon/Downloader.py | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lbrynet/core/client/StandaloneBlobDownloader.py b/lbrynet/core/client/StandaloneBlobDownloader.py index 9f637a730..5e194582d 100644 --- a/lbrynet/core/client/StandaloneBlobDownloader.py +++ b/lbrynet/core/client/StandaloneBlobDownloader.py @@ -56,7 +56,7 @@ class SingleProgressManager(object): safe_stop_looping_call(self.checker) self.finished_callback(blob_downloaded) elif self.timeout is not None: - self.timeout_counter +=1 + self.timeout_counter += 1 if self.timeout_counter >= self.timeout: safe_stop_looping_call(self.checker) self.timeout_callback() @@ -84,7 +84,7 @@ class DummyBlobHandler(object): class StandaloneBlobDownloader(object): def __init__(self, blob_hash, blob_manager, peer_finder, rate_limiter, payment_rate_manager, wallet, - timeout = None): + timeout=None): self.blob_hash = blob_hash self.blob_manager = blob_manager self.peer_finder = peer_finder diff --git a/lbrynet/daemon/Downloader.py b/lbrynet/daemon/Downloader.py index cc983d2fa..988128851 100644 --- a/lbrynet/daemon/Downloader.py +++ b/lbrynet/daemon/Downloader.py @@ -90,11 +90,9 @@ class GetStream(object): if not self.data_downloading_deferred.called: self.data_downloading_deferred.errback(Exception("Timeout")) safe_stop(self.checker) - elif self.downloader: + else: d = self.downloader.status() d.addCallback(self._check_status) - else: - log.info("Downloading stream descriptor blob (%i seconds)", self.timeout_counter) def convert_max_fee(self): currency, amount = self.max_key_fee['currency'], self.max_key_fee['amount'] @@ -184,7 +182,7 @@ class GetStream(object): def download(self, name, key_fee): # download sd blob, and start downloader self.set_status(DOWNLOAD_METADATA_CODE, name) - sd_blob = yield download_sd_blob(self.session, self.sd_hash, self.payment_rate_manager) + sd_blob = yield download_sd_blob(self.session, self.sd_hash, self.payment_rate_manager, self.timeout) self.downloader = yield self._create_downloader(sd_blob) self.set_status(DOWNLOAD_RUNNING_CODE, name) @@ -207,15 +205,10 @@ class GetStream(object): finished_deferred - deferred callbacked when download is finished """ key_fee = yield self.initialize(stream_info, name) + + yield self.download(name, key_fee) + safe_start(self.checker) - - try: - yield self.download(name, key_fee) - except Exception as err: - safe_stop(self.checker) - raise - - try: yield self.data_downloading_deferred except Exception as err: