unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Jimmy Soho <jimmy.soho@gmail.com>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Thread.current
Date: Wed, 12 Jan 2011 09:52:12 +1100	[thread overview]
Message-ID: <AANLkTim=ymsUHz8KN5niEV6kwJaMtOQyuMny-CqDSqgb@mail.gmail.com> (raw)
In-Reply-To: <AANLkTinNKpijHor6qbKwmpMXx+qqH4XYXVvxEtNOZwS5@mail.gmail.com>


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?

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..)


On Sat, Jan 8, 2011 at 4:54 PM, Jimmy Soho <jimmy.soho@gmail.com> wrote:
>>>> However, the Thread.current value within those parallel requests is
>>>> always the same.
> EW> Just a lucky coincidence :)
> I guess. Got confused there for a moment because of it. :)  Using $$
> made things more clear.
> Thanks
> Jimmy
Unicorn mailing list - mongrel-unicorn@rubyforge.org
Do not quote signatures (like this one) or top post when replying

  reply	other threads:[~2011-01-11 23:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-08  2:00 Thread.current Jimmy Soho
2011-01-08  2:57 ` Thread.current Eric Wong
2011-01-08  3:09 ` Thread.current Curtis j Schofield
2011-01-08  5:54   ` Thread.current Jimmy Soho
2011-01-11 22:52     ` Jimmy Soho [this message]
2011-01-11 23:12       ` Thread.current Eric Wong
2011-01-11 23:12       ` Thread.current Jordan Ritter
2011-01-12  3:07         ` Thread.current Jimmy Soho
2011-01-13  4:26           ` Thread.current Eric Wong
2011-01-13 16:46             ` Thread.current Jordan Ritter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTim=ymsUHz8KN5niEV6kwJaMtOQyuMny-CqDSqgb@mail.gmail.com' \
    --to=jimmy.soho@gmail.com \
    --cc=mongrel-unicorn@rubyforge.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).