From c24183aab6d2a2fa4f80c0426b544a6d16776309 Mon Sep 17 00:00:00 2001 From: rany Date: Thu, 10 Mar 2022 15:10:59 +0200 Subject: [PATCH] close files properly --- examples/02_subrip_to_mp3.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/02_subrip_to_mp3.py b/examples/02_subrip_to_mp3.py index ef42fbf..e72e926 100755 --- a/examples/02_subrip_to_mp3.py +++ b/examples/02_subrip_to_mp3.py @@ -121,7 +121,9 @@ async def _main(srt_data, voice_name, out_file): try: ensure_audio_length(fname, temporary_file.name, duration) finally: + temporary_file.close() shutil.move(temporary_file.name, fname) + temporary_file = None ffmpeg_opts = [] for i in range(len(input_files)): @@ -156,8 +158,11 @@ async def _main(srt_data, voice_name, out_file): stderr=subprocess.DEVNULL, ) finally: + temporary_file2.close() + mother_temp_file.close() shutil.move(temporary_file2.name, mother_temp_file.name) finally: + mother_temp_file.close() shutil.move(mother_temp_file.name, out_file) print("Done")