diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index b8d506378..3b42e7164 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -433,14 +433,15 @@ class Daemon(metaclass=JSONRPCServerType): self.component_startup_task = asyncio.create_task(self.component_manager.start()) 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.done(): await self.component_manager.stop() else: self.component_startup_task.cancel() log.info("stopped api components") - await self.runner.shutdown() + if shutdown_runner: + await self.runner.shutdown() await self.runner.cleanup() log.info("stopped api server") if self.analytics_manager.is_started: diff --git a/lbrynet/stream/stream_manager.py b/lbrynet/stream/stream_manager.py index e19f6c12e..ac1566d1c 100644 --- a/lbrynet/stream/stream_manager.py +++ b/lbrynet/stream/stream_manager.py @@ -7,7 +7,7 @@ import random from decimal import Decimal from aiohttp.web import Request 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.stream.descriptor import StreamDescriptor from lbrynet.stream.managed_stream import ManagedStream diff --git a/lbrynet/testcase.py b/lbrynet/testcase.py index 75854015e..29a487cf2 100644 --- a/lbrynet/testcase.py +++ b/lbrynet/testcase.py @@ -124,7 +124,7 @@ class CommandTestCase(IntegrationTestCase): async def asyncTearDown(self): await super().asyncTearDown() self.wallet_component._running = False - await self.daemon.stop() + await self.daemon.stop(shutdown_runner=False) 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. """ diff --git a/tests/integration/test_cli.py b/tests/integration/test_cli.py index a6a4c97e6..b01cf54c0 100644 --- a/tests/integration/test_cli.py +++ b/tests/integration/test_cli.py @@ -29,7 +29,7 @@ class CLIIntegrationTest(AsyncioTestCase): await self.daemon.start() async def asyncTearDown(self): - await self.daemon.stop() + await self.daemon.stop(shutdown_runner=False) def test_cli_status_command_with_auth(self): actual_output = StringIO() diff --git a/tests/integration/test_streaming.py b/tests/integration/test_streaming.py index 1c4bdc8df..832e8fed2 100644 --- a/tests/integration/test_streaming.py +++ b/tests/integration/test_streaming.py @@ -340,9 +340,11 @@ class RangeRequests(CommandTestCase): self.assertTrue(os.path.isfile(path)) await self._restart_stream_manager() stream = self.daemon.jsonrpc_file_list()[0] - - self.assertIsNone(stream.full_path) + self.assertIsNotNone(stream.full_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): return await self.test_file_save_stop_before_finished_streaming_only(wait_for_start_writing=True) diff --git a/tests/integration/test_sync.py b/tests/integration/test_sync.py index 829b47d27..f59dd72bd 100644 --- a/tests/integration/test_sync.py +++ b/tests/integration/test_sync.py @@ -54,7 +54,7 @@ class AccountSynchronization(AsyncioTestCase): async def asyncTearDown(self): 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)) def test_sync(self): diff --git a/tests/unit/stream/test_stream_manager.py b/tests/unit/stream/test_stream_manager.py index 6ca453501..b6df1d237 100644 --- a/tests/unit/stream/test_stream_manager.py +++ b/tests/unit/stream/test_stream_manager.py @@ -337,7 +337,7 @@ class TestStreamManager(BlobExchangeTestBase): 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) 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) self.assertTrue(sd_blob.file_exists)