normalperson at yhbt.net
Tue Jan 11 18:12:27 EST 2011
Jimmy Soho <jimmy.soho at gmail.com> wrote:
> Some more questions still:
> It seems a worker uses the exact same thread to handle each request.
> Is that guaranteed to happen for the lifetime of a worker? Or are
> there cases where a unicorn worker might spin a new thread to handle
> the next requests?
Unicorn itself is always single-threaded and never spawns new threads.
> If the same thread is always used, isn't that a potential issue when
> programmers use thread local variables, which are not reset at the
> next request? (I know, the usage of thread local variables is not
> recommended, but take a random rails project, go into their $GEM_HOME
> and do grep -r Thread.current . , see what I mean..)
Thats the problem of those libraries/apps, not Unicorn.
They can try Rainbows! using the :ThreadSpawn option which behaves much
like Mongrel 1, but uses Rainbows! in production that I know of.
The Rack +env+ hash is the safe/universal way to store request-local
variables across different web servers.
More information about the mongrel-unicorn