forked from LBRYCommunity/lbry-sdk
fix tests
This commit is contained in:
parent
f506b3e6d4
commit
b2f63a1545
3 changed files with 16 additions and 12 deletions
|
@ -1511,7 +1511,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
raise Exception(f'Unable to find a file for {kwargs}')
|
raise Exception(f'Unable to find a file for {kwargs}')
|
||||||
stream = streams[0]
|
stream = streams[0]
|
||||||
if status == 'start' and not stream.running:
|
if status == 'start' and not stream.running:
|
||||||
await self.stream_manager.start_stream(stream)
|
await stream.save_file(node=self.stream_manager.node)
|
||||||
msg = "Resumed download"
|
msg = "Resumed download"
|
||||||
elif status == 'stop' and stream.running:
|
elif status == 'stop' and stream.running:
|
||||||
await stream.stop()
|
await stream.stop()
|
||||||
|
|
|
@ -5,7 +5,7 @@ import logging
|
||||||
import binascii
|
import binascii
|
||||||
from aiohttp.web import Request, StreamResponse
|
from aiohttp.web import Request, StreamResponse
|
||||||
from lbrynet.utils import generate_id
|
from lbrynet.utils import generate_id
|
||||||
from lbrynet.error import DownloadSDTimeout, DownloadDataTimeout
|
from lbrynet.error import DownloadSDTimeout
|
||||||
from lbrynet.schema.mime_types import guess_media_type
|
from lbrynet.schema.mime_types import guess_media_type
|
||||||
from lbrynet.stream.downloader import StreamDownloader
|
from lbrynet.stream.downloader import StreamDownloader
|
||||||
from lbrynet.stream.descriptor import StreamDescriptor
|
from lbrynet.stream.descriptor import StreamDescriptor
|
||||||
|
@ -257,17 +257,11 @@ class ManagedStream:
|
||||||
return
|
return
|
||||||
log.info("start downloader for lbry://%s#%s (sd hash %s...)", self.claim_name, self.claim_id, self.sd_hash[:6])
|
log.info("start downloader for lbry://%s#%s (sd hash %s...)", self.claim_name, self.claim_id, self.sd_hash[:6])
|
||||||
self._running.set()
|
self._running.set()
|
||||||
start_time = self.loop.time()
|
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self.downloader.start(node), timeout, loop=self.loop)
|
await asyncio.wait_for(self.downloader.start(node), timeout, loop=self.loop)
|
||||||
if save_now:
|
|
||||||
await asyncio.wait_for(self.save_file(node=node), timeout - (self.loop.time() - start_time),
|
|
||||||
loop=self.loop)
|
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self._running.clear()
|
self._running.clear()
|
||||||
if not self.descriptor:
|
raise DownloadSDTimeout(self.sd_hash)
|
||||||
raise DownloadSDTimeout(self.sd_hash)
|
|
||||||
raise DownloadDataTimeout(self.sd_hash)
|
|
||||||
|
|
||||||
if self.delayed_stop_task and not self.delayed_stop_task.done():
|
if self.delayed_stop_task and not self.delayed_stop_task.done():
|
||||||
self.delayed_stop_task.cancel()
|
self.delayed_stop_task.cancel()
|
||||||
|
|
|
@ -7,7 +7,7 @@ import random
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from aiohttp.web import Request
|
from aiohttp.web import Request
|
||||||
from lbrynet.error import ResolveError, InvalidStreamDescriptorError, KeyFeeAboveMaxAllowed, InsufficientFundsError
|
from lbrynet.error import ResolveError, InvalidStreamDescriptorError, KeyFeeAboveMaxAllowed, InsufficientFundsError
|
||||||
from lbrynet.error import ResolveTimeout
|
from lbrynet.error import ResolveTimeout, DownloadDataTimeout
|
||||||
from lbrynet.utils import cache_concurrent
|
from lbrynet.utils import cache_concurrent
|
||||||
from lbrynet.stream.descriptor import StreamDescriptor
|
from lbrynet.stream.descriptor import StreamDescriptor
|
||||||
from lbrynet.stream.managed_stream import ManagedStream
|
from lbrynet.stream.managed_stream import ManagedStream
|
||||||
|
@ -375,13 +375,23 @@ class StreamManager:
|
||||||
analytics_manager=self.analytics_manager
|
analytics_manager=self.analytics_manager
|
||||||
)
|
)
|
||||||
log.info("starting download for %s", uri)
|
log.info("starting download for %s", uri)
|
||||||
await stream.start(self.node, timeout, save_now=save_file)
|
|
||||||
|
before_download = self.loop.time()
|
||||||
|
await stream.start(self.node, timeout)
|
||||||
|
stream.set_claim(resolved, claim)
|
||||||
if to_replace: # delete old stream now that the replacement has started downloading
|
if to_replace: # delete old stream now that the replacement has started downloading
|
||||||
await self.delete_stream(to_replace)
|
await self.delete_stream(to_replace)
|
||||||
self.streams[stream.sd_hash] = stream
|
self.streams[stream.sd_hash] = stream
|
||||||
stream.set_claim(resolved, claim)
|
|
||||||
|
self.storage.content_claim_callbacks[stream.stream_hash] = lambda: self._update_content_claim(stream)
|
||||||
await self.storage.save_content_claim(stream.stream_hash, outpoint)
|
await self.storage.save_content_claim(stream.stream_hash, outpoint)
|
||||||
|
if save_file:
|
||||||
|
await asyncio.wait_for(stream.save_file(node=self.node), timeout - (self.loop.time() - before_download),
|
||||||
|
loop=self.loop)
|
||||||
return stream
|
return stream
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
error = DownloadDataTimeout(stream.sd_hash)
|
||||||
|
raise error
|
||||||
except Exception as err: # forgive data timeout, dont delete stream
|
except Exception as err: # forgive data timeout, dont delete stream
|
||||||
error = err
|
error = err
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in a new issue