Skip to content

OSError: [Errno 24] Too many open files #3

@kafka-91

Description

@kafka-91

Hi,

I am trying to convert quite a lot of m4a files into mp3 files with the following piece of code:

for root,dirs,files in os.walk("/Users/jonathan/Desktop/Music1"): 
    for file1 in files:
        if file1[len(file1)-3:len(file1)] == "m4a":
            input1 = Input("/Users/jonathan/Desktop/Music1/"+file1)
            codec = AudioCodec("libmp3lame")
            output = Output("/Users/jonathan/Desktop/MP3/"+file1[0:len(file1)-3]+"mp3", codec) #replace the path
            ffmpeg = FFmpeg("ffmpeg", input1, output)
            ffmpeg.run()

It works fine until a certain point, when it crashes and shows the following message:
Traceback (most recent call last): File "antomp3.py", line 18, in <module> ffmpeg.run() File "/Users/jonathan/anaconda/lib/python2.7/site-packages/ffmpegwrapper-0.1_dev-py2.7.egg/ffmpegwrapper/ffmpeg.py", line 158, in run return FFmpegProcess(self).run() File "/Users/jonathan/anaconda/lib/python2.7/site-packages/ffmpegwrapper-0.1_dev-py2.7.egg/ffmpegwrapper/ffmpeg.py", line 97, in run stdin=PIPE, stdout=PIPE, stderr=STDOUT) File "/Users/jonathan/anaconda/lib/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/Users/jonathan/anaconda/lib/python2.7/subprocess.py", line 1197, in _execute_child errpipe_read, errpipe_write = self.pipe_cloexec() File "/Users/jonathan/anaconda/lib/python2.7/subprocess.py", line 1153, in pipe_cloexec r, w = os.pipe() OSError: [Errno 24] Too many open files

I've been reading about this error message on the web and it seems that it is a problem of not closing the files opened through Popen(). Can you help me fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions