forked from LBRYCommunity/lbry-sdk
fix download exceptions
This commit is contained in:
parent
9fd60c823f
commit
b7bfb259e5
1 changed files with 11 additions and 6 deletions
|
@ -612,14 +612,17 @@ class Daemon(AuthJSONRPCServer):
|
||||||
sd_hash = claim_dict.source_hash
|
sd_hash = claim_dict.source_hash
|
||||||
try:
|
try:
|
||||||
stream_hash = yield self.stream_info_manager.get_stream_hash_for_sd_hash(sd_hash)
|
stream_hash = yield self.stream_info_manager.get_stream_hash_for_sd_hash(sd_hash)
|
||||||
except NoSuchSDHash:
|
except Exception:
|
||||||
stream_hash = None
|
stream_hash = None
|
||||||
report = {
|
report = {
|
||||||
"sd_hash": sd_hash,
|
"sd_hash": sd_hash,
|
||||||
"stream_hash": stream_hash,
|
"stream_hash": stream_hash,
|
||||||
}
|
}
|
||||||
blobs = {}
|
blobs = {}
|
||||||
|
try:
|
||||||
sd_host = yield self.session.blob_manager.get_host_downloaded_from(sd_hash)
|
sd_host = yield self.session.blob_manager.get_host_downloaded_from(sd_hash)
|
||||||
|
except Exception:
|
||||||
|
sd_host = None
|
||||||
report["sd_blob"] = sd_host
|
report["sd_blob"] = sd_host
|
||||||
if stream_hash:
|
if stream_hash:
|
||||||
blob_infos = yield self.stream_info_manager.get_blobs_for_stream(stream_hash)
|
blob_infos = yield self.stream_info_manager.get_blobs_for_stream(stream_hash)
|
||||||
|
@ -628,7 +631,10 @@ class Daemon(AuthJSONRPCServer):
|
||||||
blob_infos = []
|
blob_infos = []
|
||||||
report["known_blobs"] = 0
|
report["known_blobs"] = 0
|
||||||
for blob_hash, blob_num, iv, length in blob_infos:
|
for blob_hash, blob_num, iv, length in blob_infos:
|
||||||
|
try:
|
||||||
host = yield self.session.blob_manager.get_host_downloaded_from(blob_hash)
|
host = yield self.session.blob_manager.get_host_downloaded_from(blob_hash)
|
||||||
|
except Exception:
|
||||||
|
host = None
|
||||||
if host:
|
if host:
|
||||||
blobs[blob_num] = host
|
blobs[blob_num] = host
|
||||||
report["blobs"] = json.dumps(blobs)
|
report["blobs"] = json.dumps(blobs)
|
||||||
|
@ -643,13 +649,11 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _download_finished(download_id, name, claim_dict):
|
def _download_finished(download_id, name, claim_dict):
|
||||||
log.info("Finished: %s", name)
|
|
||||||
report = yield self._get_stream_analytics_report(claim_dict)
|
report = yield self._get_stream_analytics_report(claim_dict)
|
||||||
self.analytics_manager.send_download_finished(download_id, name, report, claim_dict)
|
self.analytics_manager.send_download_finished(download_id, name, report, claim_dict)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _download_failed(error, download_id, name, claim_dict):
|
def _download_failed(error, download_id, name, claim_dict):
|
||||||
log.warning("Failed %s: %s", name, error)
|
|
||||||
report = yield self._get_stream_analytics_report(claim_dict)
|
report = yield self._get_stream_analytics_report(claim_dict)
|
||||||
self.analytics_manager.send_download_errored(error, download_id, name, claim_dict,
|
self.analytics_manager.send_download_errored(error, download_id, name, claim_dict,
|
||||||
report)
|
report)
|
||||||
|
@ -684,6 +688,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
yield self.streams[claim_id].downloader.stop(err)
|
yield self.streams[claim_id].downloader.stop(err)
|
||||||
yield _download_failed(err, download_id, name, claim_dict)
|
yield _download_failed(err, download_id, name, claim_dict)
|
||||||
result = {'error': err.message}
|
result = {'error': err.message}
|
||||||
|
finally:
|
||||||
del self.streams[claim_id]
|
del self.streams[claim_id]
|
||||||
defer.returnValue(result)
|
defer.returnValue(result)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue