For the record, the "clear the Thread.current storage before/after each request" is what I think is a crappy idiom. YMMV I guess.
cheers, --jordan On Jan 12, 2011, at 8:26 PM, Eric Wong wrote: > Jimmy Soho <[email protected]> wrote: >> Take for example activesupport's usage of Time.zone. Under water this >> is set in a thread local var. If you set Time.zone 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 > EOF > > And then just run "rainbows" instead of "unicorn". > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - [email protected] > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
