This commit is contained in:
Jack Robison 2019-05-03 20:50:11 -04:00
parent f7412514b3
commit f506b3e6d4
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
7 changed files with 12 additions and 9 deletions

View file

@ -433,14 +433,15 @@ class Daemon(metaclass=JSONRPCServerType):
self.component_startup_task = asyncio.create_task(self.component_manager.start()) self.component_startup_task = asyncio.create_task(self.component_manager.start())
await self.component_startup_task await self.component_startup_task
async def stop(self): async def stop(self, shutdown_runner=True):
if self.component_startup_task is not None: if self.component_startup_task is not None:
if self.component_startup_task.done(): if self.component_startup_task.done():
await self.component_manager.stop() await self.component_manager.stop()
else: else:
self.component_startup_task.cancel() self.component_startup_task.cancel()
log.info("stopped api components") log.info("stopped api components")
await self.runner.shutdown() if shutdown_runner:
await self.runner.shutdown()
await self.runner.cleanup() await self.runner.cleanup()
log.info("stopped api server") log.info("stopped api server")
if self.analytics_manager.is_started: if self.analytics_manager.is_started:

View file

@ -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, DownloadDataTimeout, DownloadSDTimeout from lbrynet.error import ResolveTimeout
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

View file

@ -124,7 +124,7 @@ class CommandTestCase(IntegrationTestCase):
async def asyncTearDown(self): async def asyncTearDown(self):
await super().asyncTearDown() await super().asyncTearDown()
self.wallet_component._running = False self.wallet_component._running = False
await self.daemon.stop() await self.daemon.stop(shutdown_runner=False)
async def confirm_tx(self, txid): async def confirm_tx(self, txid):
""" Wait for tx to be in mempool, then generate a block, wait for tx to be in a block. """ """ Wait for tx to be in mempool, then generate a block, wait for tx to be in a block. """

View file

@ -29,7 +29,7 @@ class CLIIntegrationTest(AsyncioTestCase):
await self.daemon.start() await self.daemon.start()
async def asyncTearDown(self): async def asyncTearDown(self):
await self.daemon.stop() await self.daemon.stop(shutdown_runner=False)
def test_cli_status_command_with_auth(self): def test_cli_status_command_with_auth(self):
actual_output = StringIO() actual_output = StringIO()

View file

@ -340,9 +340,11 @@ class RangeRequests(CommandTestCase):
self.assertTrue(os.path.isfile(path)) self.assertTrue(os.path.isfile(path))
await self._restart_stream_manager() await self._restart_stream_manager()
stream = self.daemon.jsonrpc_file_list()[0] stream = self.daemon.jsonrpc_file_list()[0]
self.assertIsNotNone(stream.full_path)
self.assertIsNone(stream.full_path)
self.assertFalse(os.path.isfile(path)) self.assertFalse(os.path.isfile(path))
if wait_for_start_writing:
await stream.started_writing.wait()
self.assertTrue(os.path.isfile(path))
async def test_file_save_stop_before_finished_streaming_only_wait_for_start(self): async def test_file_save_stop_before_finished_streaming_only_wait_for_start(self):
return await self.test_file_save_stop_before_finished_streaming_only(wait_for_start_writing=True) return await self.test_file_save_stop_before_finished_streaming_only(wait_for_start_writing=True)

View file

@ -54,7 +54,7 @@ class AccountSynchronization(AsyncioTestCase):
async def asyncTearDown(self): async def asyncTearDown(self):
self.wallet_component._running = False self.wallet_component._running = False
await self.daemon.stop() await self.daemon.stop(shutdown_runner=False)
@mock.patch('time.time', mock.Mock(return_value=12345)) @mock.patch('time.time', mock.Mock(return_value=12345))
def test_sync(self): def test_sync(self):

View file

@ -337,7 +337,7 @@ class TestStreamManager(BlobExchangeTestBase):
for blob_hash in [stream.sd_hash] + [b.blob_hash for b in stream.descriptor.blobs[:-1]]: for blob_hash in [stream.sd_hash] + [b.blob_hash for b in stream.descriptor.blobs[:-1]]:
blob_status = await self.client_storage.get_blob_status(blob_hash) blob_status = await self.client_storage.get_blob_status(blob_hash)
self.assertEqual('pending', blob_status) self.assertEqual('pending', blob_status)
self.assertEqual('stopped', self.stream_manager.streams[self.sd_hash].status) self.assertEqual('finished', self.stream_manager.streams[self.sd_hash].status)
sd_blob = self.client_blob_manager.get_blob(stream.sd_hash) sd_blob = self.client_blob_manager.get_blob(stream.sd_hash)
self.assertTrue(sd_blob.file_exists) self.assertTrue(sd_blob.file_exists)