Skip to content

Commit e5ca967

Browse files
moodyjoneukreign
authored andcommitted
Make FileManager.stop() async because SourceManager.stop() is now async.
1 parent eed7d02 commit e5ca967

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

lbry/extras/daemon/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ async def start(self):
374374
log.info('Done setting up file manager')
375375

376376
async def stop(self):
377-
self.file_manager.stop()
377+
await self.file_manager.stop()
378378

379379

380380
class BackgroundDownloaderComponent(Component):

lbry/file/file_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ async def start(self):
5050
await manager.started.wait()
5151
self.started.set()
5252

53-
def stop(self):
53+
async def stop(self):
5454
for manager in self.source_managers.values():
5555
# fixme: pop or not?
56-
manager.stop()
56+
await manager.stop()
5757
self.started.clear()
5858

5959
@cache_concurrent

tests/integration/datanetwork/test_file_commands.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ async def test_filename_conflicts_management_on_resume_download(self):
354354
await self.daemon.jsonrpc_get('lbry://foo')
355355
with open(original_path, 'wb') as handle:
356356
handle.write(b'some other stuff was there instead')
357-
self.daemon.file_manager.stop()
357+
await self.daemon.file_manager.stop()
358358
await self.daemon.file_manager.start()
359359
await asyncio.wait_for(self.wait_files_to_complete(), timeout=5) # if this hangs, file didn't get set completed
360360
# check that internal state got through up to the file list API
@@ -382,8 +382,7 @@ async def test_incomplete_downloads_erases_output_file_on_stop(self):
382382
resp = await self.out(self.daemon.jsonrpc_get('lbry://foo', timeout=2))
383383
self.assertNotIn('error', resp)
384384
self.assertTrue(os.path.isfile(path))
385-
self.daemon.file_manager.stop()
386-
await asyncio.sleep(0.01) # FIXME: this sleep should not be needed
385+
await self.daemon.file_manager.stop()
387386
self.assertFalse(os.path.isfile(path))
388387

389388
async def test_incomplete_downloads_retry(self):
@@ -478,7 +477,7 @@ async def test_paid_download(self):
478477

479478
# restart the daemon and make sure the fee is still there
480479

481-
self.daemon.file_manager.stop()
480+
await self.daemon.file_manager.stop()
482481
await self.daemon.file_manager.start()
483482
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
484483
self.assertEqual((await self.daemon.jsonrpc_file_list())['items'][0].content_fee.raw, raw_content_fee)

tests/integration/datanetwork/test_streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_random_bytes(n: int) -> bytes:
2121

2222
class RangeRequests(CommandTestCase):
2323
async def _restart_stream_manager(self):
24-
self.daemon.file_manager.stop()
24+
await self.daemon.file_manager.stop()
2525
await self.daemon.file_manager.start()
2626
return
2727

0 commit comments

Comments
 (0)