Jordan Ritter jpr5 at
Thu Jan 13 11:46:23 EST 2011

For the record, the "clear the Thread.current storage before/after each request" is what I think is a crappy idiom.  YMMV I guess.


On Jan 12, 2011, at 8:26 PM, Eric Wong wrote:

> Jimmy Soho <jimmy.soho at> wrote:
>> Take for example activesupport's usage of Under water this
>> is set in a thread local var. If you set in one request, but
>> not in the next request, using unicorn the next request will use the
>> time zone of the previous request. Using rack or mongrel (in
>> multithreaded mode) you don't have this issue perse (though they have
>> other issues then).
>> Same for the i18n gem and it's usage of the I18n.locale value, which
>> is also set in a thread local var.
>> So yeah, unfortunately I have to take into account this "crappy idiom"
>> and need to know exactly which thread local vars are set by all the
>> components we use, and determine which of those must be reset before
>> each request.
> You can probably just write a trivial middleware to clear all
> keys in Thread.current before every request.  Or play around with
> Rainbows! with a single-threaded ThreadSpawn:
> cat >> unicorn.conf.rb <<EOF
> Rainbows! do
>  use :ThreadSpawn
>  worker_connections 1
>  keepalive_timeout 0
> end
> And then just run "rainbows" instead of "unicorn".
> -- 
> Eric Wong
> _______________________________________________
> Unicorn mailing list - mongrel-unicorn at
> Do not quote signatures (like this one) or top post when replying

More information about the mongrel-unicorn mailing list