我在Windows上使用Python2.7。我的脚本依赖于tempfile.mkstemp和tempfile.mkdtemp创建许多文件和目录,其模式如下:
_,_tmp = mkstemp(prefix=section,dir=indir,text脚本试图打开的实际文件各不相同。OSError: [Errno 24] Too many open files: 'path\\to\\most\\recent\\attempt\\to\\open\\file
我在Windows上通过python2.7运行ghostscript,将一堆1页的PDF文件转换成TIFF图像。output_pdf_folder + pagefile, output_tif_folder + pagefile[:-4] + ".tif")在转换大约114个文件后,我得到以下错误- OSError: Too many open files
其他关于类似问题的帖子建议应该优雅地关闭文件描述符,但由
当我使用完Queue时,我会尽力关闭和清理它们,以便从Python的多处理模块中的进程中收集输出。以下是一些代码,由于“打开的文件太多”,在某个时候会死掉。我还能做些什么来清理完整的工作/队列,这样我就可以做我想做的事情了?to avoid the OSError of too many files open.,所以在我的代码中没有引起问题的特定行。li