我正在运行两个脚本,过了一会儿,我
Too many open files @ error/blob.c/ImageToFile/1832
.
第一个脚本的简化版本。它应该读取写入图像管道的图像,对其进行处理,然后将其写入OCR管道以供OCR读取。
# creates 2 named pipes
File.mkfifo(image_pipe) rescue nil
File.mkfifo(ocr_pipe) rescue nil
while image = Image.read(image_pipe)
# do some stuff with `image`...
end
第二个脚本使用ffmpeg从视频中提取帧,并将其写入
image_pipe
# image_pipe is the same as the script above.
(14..movie.duration).step(0.5) do
`/usr/local/bin/ffmpeg [some options...] #{image_pipe}`
end
我认为问题在于,在读取第一个脚本循环中的图像时,rmagic打开了太多的文件描述符,但我不确定如何阻止这种情况发生。这个
Magick::Image
班级没有
close
方法或任何东西,阿法克。