From 11510191863d6ff8f1af4dddb5d2b8af30f2b001 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Wed, 11 Jan 2017 11:35:53 -0600 Subject: [PATCH] Improve downloader error handling Instead of having an error cause a timeout, send the error directly to the callback --- lbrynet/lbrynet_daemon/Downloader.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Downloader.py b/lbrynet/lbrynet_daemon/Downloader.py index f17fb34e3..44cc674e2 100644 --- a/lbrynet/lbrynet_daemon/Downloader.py +++ b/lbrynet/lbrynet_daemon/Downloader.py @@ -85,9 +85,10 @@ class GetStream(object): return self.exchange_rate_manager.to_lbc(self.max_key_fee).amount def start(self, stream_info, name): - def _cause_timeout(err): - log.info('Cancelling download') - self.timeout_counter = self.timeout * 2 + def _cancel(err): + if self.checker: + self.checker.stop() + self.finished.errback(err) def _set_status(x, status): log.info("Download lbry://%s status changed to %s" % (self.resolved_name, status)) @@ -138,7 +139,7 @@ class GetStream(object): self._d.addCallback(lambda r: _set_status(r, DOWNLOAD_RUNNING_CODE)) self._d.addCallback(get_downloader_factory) self._d.addCallback(make_downloader) - self._d.addCallbacks(self._start_download, _cause_timeout) + self._d.addCallbacks(self._start_download, _cancel) self._d.callback(None) return self.finished