What does config.threadsafe! actually do?


#1

Does anyone know what config.threadsafe! actually does, what effect(s)
it has? I’m even sure where to go looking in the source code for
effects of a config variable like that, but if someone has source to
recommend, I’ll give it a shot (although I sometimes have trouble
comprehending AR source, I must admit).

I know it tells Rails to do concurrency request handling. Okay, so far
so good. But I suspect it does other things to to them make Rails behave
differently to support concurrent request handling, rather than simply
remove a mutex around the event loop or whatever.

I ask this because, while I’m not actually interested in concurrent
request handling (don’t need it), I do use threads in my Rails app for
other purposes. (Dealing with long-running processes, dealing with
talking to slow external web services). I’m actually surprised that
nobody else seems to have a use case for this, but in my app it’s pretty
crucial. So I’m trying to figure out what Rails 2.2 can do for me, and
how I’ll have to change my Rails 2.1 code to deal with it, etc… The
changes around supporting threading more intentionally are potentially
good, but the only documentation or writing I can find on it (and very
little of that) assumes you are interested in concurrent request
handling.

Since I’m not, I don’t neccesarily want to call config.threadsafe!. But
I’m wondering if there are side effects of config.threadsafe! that I
might want to trigger myself, to make Rails happier about handling
multiple threads (possibly with AR) even without concurrent request
handling.

Anyone have any info to point me to?


#2

There is some good information right in the rails 2.2 release notes
along with links to blogs with more information.
http://guides.rubyonrails.org/2_2_release_notes.html#_thread_safety

Aaron


#3

Aaron B. wrote:

There is some good information right in the rails 2.2 release notes
along with links to blogs with more information.
http://guides.rubyonrails.org/2_2_release_notes.html#_thread_safety

Thanks Aaron. I definitely checked that out before posting, but it (and
it’s links) don’t have quite enough information for me. They don’t
really say what config.threadsafe! does, except for allow concurrent
request handling.

Guess I’ll have to dive into the source at some point.