On 20 Nov 2009, at 12:32, Lionel Bouton wrote:

> 
> BTW, if you use threads, you should join each thread (or try to) to have
> at least some control over the number of threads running concurrently.
> 
> If not, each time you loop over such code you create new threads (which
> probably will use new DB connections, I'm not sure how the ActiveRecord
> DB connection pool is used when ActiveRecord is used in a threaded
> environment) without any guarantee that previous ones finish.

You should bracket the databasey bits with
ActiveRecord::Base.connection_pool.with_connection do

end

to ensure that your connection is returned to the pool (otherwise once you have 
consumed the number of connections in the pool your threads will start to block 
until the wait for new connection timeout expires.

Fred
> 
> Lionel
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=.
> 
> 

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=.


Reply via email to