fix download timeout types
This commit is contained in:
parent
266e777655
commit
e2170ec83d
2 changed files with 8 additions and 3 deletions
|
@ -1576,6 +1576,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
if not stream:
|
if not stream:
|
||||||
raise DownloadSDTimeout(uri)
|
raise DownloadSDTimeout(uri)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
log.warning("Error downloading %s: %s", uri, str(e))
|
||||||
return {"error": str(e)}
|
return {"error": str(e)}
|
||||||
else:
|
else:
|
||||||
return stream.as_dict()
|
return stream.as_dict()
|
||||||
|
|
|
@ -4,7 +4,8 @@ import typing
|
||||||
import binascii
|
import binascii
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from lbrynet.error import ResolveError, InvalidStreamDescriptorError, KeyFeeAboveMaxAllowed, InsufficientFundsError
|
from lbrynet.error import ResolveError, InvalidStreamDescriptorError, KeyFeeAboveMaxAllowed, InsufficientFundsError, \
|
||||||
|
DownloadDataTimeout, DownloadSDTimeout
|
||||||
from lbrynet.stream.downloader import StreamDownloader
|
from lbrynet.stream.downloader import StreamDownloader
|
||||||
from lbrynet.stream.managed_stream import ManagedStream
|
from lbrynet.stream.managed_stream import ManagedStream
|
||||||
from lbrynet.schema.claim import ClaimDict
|
from lbrynet.schema.claim import ClaimDict
|
||||||
|
@ -249,7 +250,7 @@ class StreamManager:
|
||||||
log.info("stream timeout")
|
log.info("stream timeout")
|
||||||
downloader.stop()
|
downloader.stop()
|
||||||
log.info("stopped stream")
|
log.info("stopped stream")
|
||||||
return
|
raise DownloadSDTimeout(downloader.sd_hash)
|
||||||
file_name = os.path.basename(downloader.output_path)
|
file_name = os.path.basename(downloader.output_path)
|
||||||
download_directory = os.path.dirname(downloader.output_path)
|
download_directory = os.path.dirname(downloader.output_path)
|
||||||
if not await self.blob_manager.storage.stream_exists(downloader.sd_hash):
|
if not await self.blob_manager.storage.stream_exists(downloader.sd_hash):
|
||||||
|
@ -273,6 +274,7 @@ class StreamManager:
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
downloader.stop()
|
downloader.stop()
|
||||||
log.debug("stopped stream")
|
log.debug("stopped stream")
|
||||||
|
raise DownloadDataTimeout(downloader.sd_hash)
|
||||||
|
|
||||||
async def download_stream_from_claim(self, node: 'Node', claim_info: typing.Dict,
|
async def download_stream_from_claim(self, node: 'Node', claim_info: typing.Dict,
|
||||||
file_name: typing.Optional[str] = None,
|
file_name: typing.Optional[str] = None,
|
||||||
|
@ -298,7 +300,9 @@ class StreamManager:
|
||||||
if should_pay and fee_address and fee_amount:
|
if should_pay and fee_address and fee_amount:
|
||||||
await self.wallet.send_amount_to_address(lbc_to_dewies(str(fee_amount)), fee_address.encode('latin1'))
|
await self.wallet.send_amount_to_address(lbc_to_dewies(str(fee_amount)), fee_address.encode('latin1'))
|
||||||
return stream
|
return stream
|
||||||
except (asyncio.TimeoutError, asyncio.CancelledError):
|
except (asyncio.TimeoutError, asyncio.CancelledError) as e:
|
||||||
|
if stream_task.exception():
|
||||||
|
raise stream_task.exception()
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
if sd_hash in self.starting_streams:
|
if sd_hash in self.starting_streams:
|
||||||
|
|
Loading…
Add table
Reference in a new issue