简体   繁体   中英

Error with R function download.file: Too many open files

I am using:

 download.file(url,path_file,mode="wb",quiet=quiet)

with R version 3.2.3 (2015-12-10) on Windows 7 to copy a big amount of images (TIFF files). I have to copy a huge number of files: 300'00 but it failed at some point with the following issue:

"cannot open destfile 'tmp/74114070005_531__0.tiff' , reason 'Too many open files'"

The issue is that from time to time the copy of the url failed and R create a empty file with a size of 0 Byte but Windows lock the file so I cannot remove it. So the failed file stay open until I exit R. After a certain number of failed copy then I got the error above that "too many open file"

Is there a way to close the connection for each file ? I tried closeAllConnections() but this has not impact.

Is there a way to run a R command line that will "restart" the R programm so Windows will unlock the files ?

Any other idea are welcome.

Thanks

Fabien

This is an issue with Windows that locked files. The best things is to avoid Windows. For people that need to use Windows there is a solution. I tested it with Windows 7:

This avoid to have all these locked files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM