add download_sd_blob timeout to GetStream
This commit is contained in:
parent
bd4dd8e114
commit
fc40f5525a
2 changed files with 7 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
safe_start(self.checker)
|
||||
|
||||
try:
|
||||
yield self.download(name, key_fee)
|
||||
except Exception as err:
|
||||
safe_stop(self.checker)
|
||||
raise
|
||||
|
||||
|
||||
safe_start(self.checker)
|
||||
try:
|
||||
yield self.data_downloading_deferred
|
||||
except Exception as err:
|
||||
|
|
Loading…
Reference in a new issue