[R] Too many open files

From: Markus Loecher <markus_at_insightfromdata.com>
Date: Thu, 27 Dec 2007 10:56:32 -0500

Dear all,
Did this problem that was posted in 2006 (see below) ever got fully resolved ?
I am encountering the exact same issue
; I have executed get.hist.quote() in a loop and now R not only refuses to establish any further connections to yahoo, but, worse, it will not open any files either. For example, I cannot even save my current workspace for that reason.
I tried
As well as
But I do not see any open connections.
Also, does get.hist.quote() not close its connection internally once it is done ?

Any help would be immensely useful as I am quite stuck. Thanks!


Re: [R] Too many open files

From: Seth Falcon <sfalcon_at_fhcrc.org> Date: Sat 27 May 2006 - 09:21:36 EST

"Omar Lakkis" <uofiowa_at_gmail.com> writes:

> This may be more of an OS question ...
> I have this call
> r = get.hist.quote(symbol, start= format(start, "%Y-%m-%d"), end=
> format(end, "%Y-%m-%d"))
> which does a url request
> in a loop and my program runs out of file handlers after few hundred
> rotations. The error message is: 'Too many open files'. Other than
> increasing the file handlers assigned to my process, is there a way to
> cleanly release and reuse these connections?

Inside your loop you need to close the connection object created by url().

for (i in 1:500) {

    con <- url(urls[i])
    ## ... stuff here ...

R only allows you to have a fixed number of open connections at one time, and they do not get closed automatically when they go out of scope. These commands may help make clear how things work...

> showConnections()

     description class mode text isopen can read can write
> f = url("http://www.r-project.org", open="r")
> showConnections()

From: Gabor Grothendieck <ggrothendieck_at_gmail.com> Date: Sat 27 May 2006 - 09:47:20 EST

Try closeAllConnections()

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 27 Dec 2007 - 16:01:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 27 Dec 2007 - 16:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.