add download_sd_blob timeout to GetStream

This commit is contained in:
Kay Kurokawa 2017-06-21 11:45:38 -04:00
parent bd4dd8e114
commit fc40f5525a
2 changed files with 7 additions and 14 deletions

View file

@ -90,11 +90,9 @@ class GetStream(object):
if not self.data_downloading_deferred.called: if not self.data_downloading_deferred.called:
self.data_downloading_deferred.errback(Exception("Timeout")) self.data_downloading_deferred.errback(Exception("Timeout"))
safe_stop(self.checker) safe_stop(self.checker)
elif self.downloader: else:
d = self.downloader.status() d = self.downloader.status()
d.addCallback(self._check_status) d.addCallback(self._check_status)
else:
log.info("Downloading stream descriptor blob (%i seconds)", self.timeout_counter)
def convert_max_fee(self): def convert_max_fee(self):
currency, amount = self.max_key_fee['currency'], self.max_key_fee['amount'] 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): def download(self, name, key_fee):
# download sd blob, and start downloader # download sd blob, and start downloader
self.set_status(DOWNLOAD_METADATA_CODE, name) 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.downloader = yield self._create_downloader(sd_blob)
self.set_status(DOWNLOAD_RUNNING_CODE, name) self.set_status(DOWNLOAD_RUNNING_CODE, name)
@ -207,15 +205,10 @@ class GetStream(object):
finished_deferred - deferred callbacked when download is finished finished_deferred - deferred callbacked when download is finished
""" """
key_fee = yield self.initialize(stream_info, name) key_fee = yield self.initialize(stream_info, name)
safe_start(self.checker)
try:
yield self.download(name, key_fee) yield self.download(name, key_fee)
except Exception as err:
safe_stop(self.checker)
raise
safe_start(self.checker)
try: try:
yield self.data_downloading_deferred yield self.data_downloading_deferred
except Exception as err: except Exception as err: