forked from LBRYCommunity/lbry-sdk
Merge pull request #115 from lbryio/get-stream-timeout
raise Exception on GetStream timeout
This commit is contained in:
commit
4e2296d5f6
2 changed files with 10 additions and 2 deletions
|
@ -1785,6 +1785,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
stream_info=params.stream_info,
|
||||
file_name=params.file_name,
|
||||
wait_for_write=params.wait_for_write)
|
||||
# TODO: downloading can timeout. Not sure what to do when that happens
|
||||
d.addCallback(get_output_callback(params))
|
||||
d.addCallback(lambda message: self._render_response(message, OK_CODE))
|
||||
return d
|
||||
|
@ -2558,6 +2559,13 @@ class _DownloadNameHelper(object):
|
|||
def _get_stream(self, stream_info):
|
||||
d = self.daemon.add_stream(
|
||||
self.name, self.timeout, self.download_directory, self.file_name, stream_info)
|
||||
|
||||
def _raiseErrorOnTimeout(args):
|
||||
was_successful, _, _ = args
|
||||
if not was_successful:
|
||||
raise Exception('What am I supposed to do with a timed-out downloader?')
|
||||
d.addCallback(_raiseErrorOnTimeout)
|
||||
|
||||
if self.wait_for_write:
|
||||
d.addCallback(lambda _: self._wait_for_write())
|
||||
d.addCallback(lambda _: self.daemon.streams[self.name].downloader)
|
||||
|
|
|
@ -75,14 +75,14 @@ class GetStream(object):
|
|||
# TODO: Why is this the stopping condition for the finished callback?
|
||||
if self.download_path:
|
||||
self.checker.stop()
|
||||
self.finished.callback((self.stream_hash, self.download_path))
|
||||
self.finished.callback((True, self.stream_hash, self.download_path))
|
||||
|
||||
elif self.timeout_counter >= self.timeout:
|
||||
log.info("Timeout downloading lbry://%s" % self.resolved_name)
|
||||
self.checker.stop()
|
||||
self.d.cancel()
|
||||
self.code = STREAM_STAGES[4]
|
||||
self.finished.callback(False)
|
||||
self.finished.callback((False, None, None))
|
||||
|
||||
def _convert_max_fee(self):
|
||||
if isinstance(self.max_key_fee, dict):
|
||||
|
|
Loading…
Reference in a new issue