Eric Wong normalperson at
Wed Jan 12 23:26:36 EST 2011

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

And then just run "rainbows" instead of "unicorn".

Eric Wong

More information about the mongrel-unicorn mailing list