One suggestion could be like this,so here wait live in a none blocking way using asyncio
import asyncio from pathlib import Path async def file_exists(file_path: Path) -> bool: """Asynchronously check if a file exists.""" await asyncio.sleep(0.5) return file_path.exists() async def wait_until_all_files_exist(file_paths: tuple[Path]): """Wait until all specified files exist, with periodic updates every 10 seconds.""" while True: results = await asyncio.gather(*(file_exists(fp) for fp in file_paths)) if all(results): print("All files found") break else: # List missing files missing_files = [fp for fp, exists in zip(file_paths, results) if not exists] print(f"Still missing files: {', '.join(str(mf) for mf in missing_files)}") await asyncio.sleep(10) async def main(): await wait_until_all_files_exist((Path('file1.txt'), Path('file2.txt'), Path('file3.txt'))) asyncio.run(main())If run this will work like this,as soon as it make file2.txt and file3.txt in folder will update until all done.
G:\div_code\reader_env λ python all_files_1.py Still missing files: file2.txt, file3.txt Still missing files: file2.txt, file3.txt Still missing files: file3.txt Still missing files: file3.txt Still missing files: file3.txt Still missing files: file3.txt All files found