From 36dea2afbf0404cf600a139831aedee2576f424f Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Wed, 21 Jun 2017 13:35:15 -0400 Subject: [PATCH] use timeout in Daemon._download_blob() --- lbrynet/daemon/Daemon.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index a4f8115d2..7c3ab8216 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -599,26 +599,12 @@ class Daemon(AuthJSONRPCServer): :param timeout (int): blob timeout :return: BlobFile """ - - def cb(blob): - if not finished_d.called: - finished_d.callback(blob) - - def eb(): - if not finished_d.called: - finished_d.errback(Exception("Blob (%s) download timed out" % - blob_hash[:SHORT_ID_LEN])) - if not blob_hash: raise Exception("Nothing to download") rate_manager = rate_manager or self.session.payment_rate_manager timeout = timeout or 30 - finished_d = defer.Deferred(None) - reactor.callLater(timeout, eb) - d = download_sd_blob(self.session, blob_hash, rate_manager) - d.addCallback(cb) - return finished_d + return download_sd_blob(self.session, blob_hash, rate_manager, timeout) @defer.inlineCallbacks def _download_name(self, name, claim_dict, claim_id, timeout=None, file_name=None):