RE: Re: Re: Re: #<Errno::EMFILE: Too many open files

automatically closes

the
file for you

how do you know it is closing them? what shows in lsof?

I know because that’s what File.open does for you. Just like
file.close
closes a file, so does File.open.

I’d verify that just to be sure. In 1.8.3 a bug was introduced where
subclasses of IO did not automatically call .close in block form. See
http://rubyforge.org/tracker/index.php?func=detail&aid=4898&group_id=426
&atid=1698 (or ruby-core:6911).

However, I was under the impression that the core classes were
unaffected. I ran this snippet on my Windows box with 1.8.4 just to
verify:

10000.times{
File.open(“test.txt”,“w”){ |fh| fh.puts “hello” }
sleep 1
}

Then I watched the handle and thread count in the process manager. They
never increased.

I haven’t validated this on all platforms, however.

Regards,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs