diff --git a/lbrynet/blob/client/EncryptedFileDownloader.py b/lbrynet/blob/client/EncryptedFileDownloader.py index 6ab621595..45855d79d 100644 --- a/lbrynet/blob/client/EncryptedFileDownloader.py +++ b/lbrynet/blob/client/EncryptedFileDownloader.py @@ -168,16 +168,12 @@ class EncryptedFileSaver(EncryptedFileDownloader): def _close_output(self): self.file_handle, file_handle = None, self.file_handle - - #def close_file(): if file_handle is not None: name = file_handle.name file_handle.close() if self.completed is False: os.remove(name) - #return threads.deferToThread(close_file) - def _get_write_func(self): def write_func(data): if self.stopped is False and self.file_handle is not None: diff --git a/lbrynet/blob/client/EncryptedFileMetadataHandler.py b/lbrynet/blob/client/EncryptedFileMetadataHandler.py index 9195bb7a7..e7a7b1c25 100644 --- a/lbrynet/blob/client/EncryptedFileMetadataHandler.py +++ b/lbrynet/blob/client/EncryptedFileMetadataHandler.py @@ -19,8 +19,7 @@ class EncryptedFileMetadataHandler: @defer.inlineCallbacks def get_initial_blobs(self): blob_infos = yield f2d(self.storage.get_blobs_for_stream(self.stream_hash)) - formatted_infos = self._format_initial_blobs_for_download_manager(blob_infos) - defer.returnValue(formatted_infos) + return self._format_initial_blobs_for_download_manager(blob_infos) def final_blob_num(self): return self._final_blob_num diff --git a/lbrynet/extras/cli.py b/lbrynet/extras/cli.py index 97b9aad8c..34b959dd9 100644 --- a/lbrynet/extras/cli.py +++ b/lbrynet/extras/cli.py @@ -57,7 +57,7 @@ def start_daemon(settings: typing.Optional[typing.Dict] = None, if check_connection(): daemon = Daemon() - asyncio.get_event_loop().create_task(daemon.start_listening()) + asyncio.create_task(daemon.start_listening()) reactor.run() else: log.info("Not connected to internet, unable to start") diff --git a/lbrynet/p2p/client/DownloadManager.py b/lbrynet/p2p/client/DownloadManager.py index 54a29e5c2..d73c049d9 100644 --- a/lbrynet/p2p/client/DownloadManager.py +++ b/lbrynet/p2p/client/DownloadManager.py @@ -30,7 +30,7 @@ class DownloadManager: def resume_downloading(self): yield self.connection_manager.start() yield self.progress_manager.start() - defer.returnValue(True) + return True @defer.inlineCallbacks def stop_downloading(self): @@ -40,18 +40,13 @@ class DownloadManager: def add_blobs_to_download(self, blob_infos): log.debug("Adding %s blobs to blobs", len(blob_infos)) - def add_blob_to_list(blob, blob_num): - self.blobs[blob_num] = blob - log.debug( - "Added blob (hash: %s, number %s) to the list", blob.blob_hash, blob_num) - for blob_info in blob_infos: if not blob_info.blob_num in self.blobs: self.blob_infos[blob_info.blob_num] = blob_info - log.debug( - "Trying to get the blob associated with blob hash %s", blob_info.blob_hash) + log.debug("Trying to get the blob associated with blob hash %s", blob_info.blob_hash) blob = self.blob_manager.get_blob(blob_info.blob_hash, blob_info.length) - add_blob_to_list(blob, blob_info.blob_num) + self.blobs[blob_info.blob_num] = blob + log.debug("Added blob (hash: %s, number %s) to the list", blob.blob_hash, blob_info.blob_num) def stream_position(self): return self.progress_manager.stream_position() diff --git a/tests/functional/test_misc.py b/tests/functional/test_misc.py index f0db9031e..bbe880bdb 100644 --- a/tests/functional/test_misc.py +++ b/tests/functional/test_misc.py @@ -105,7 +105,7 @@ class LbryUploader: for lbry_file in lbry_files: yield self.lbry_file_manager.delete_lbry_file(lbry_file) yield self.lbry_file_manager.stop() - yield self.blob_manager.stop() + yield f2d(self.blob_manager.stop()) yield f2d(self.storage.close()) self.server_port.stopListening() rm_db_and_blob_dir(self.db_dir, self.blob_dir) @@ -115,6 +115,7 @@ class LbryUploader: @skip class TestTransfer(unittest.TestCase): + @defer.inlineCallbacks def setUp(self): mocks.mock_conf_settings(self) diff --git a/tests/unit/database/test_SQLiteStorage.py b/tests/unit/database/test_SQLiteStorage.py index bac241cb9..511277346 100644 --- a/tests/unit/database/test_SQLiteStorage.py +++ b/tests/unit/database/test_SQLiteStorage.py @@ -238,10 +238,11 @@ class StreamStorageTests(StorageTest): class FileStorageTests(StorageTest): - async def test_setup_output(self): + @defer.inlineCallbacks + def test_setup_output(self): file_name = 'encrypted_file_saver_test.tmp' self.assertFalse(os.path.isfile(file_name)) - written_to = await open_file_for_writing(self.db_dir, file_name) + written_to = yield f2d(open_file_for_writing(self.db_dir, file_name)) self.assertEqual(written_to, file_name) self.assertTrue(os.path.isfile(os.path.join(self.db_dir, file_name))) @@ -285,6 +286,7 @@ class FileStorageTests(StorageTest): class ContentClaimStorageTests(StorageTest): + @defer.inlineCallbacks def test_store_content_claim(self): download_directory = self.db_dir