unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Curtis j Schofield <curtis.schofield@gmail.com>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Thread.current
Date: Fri, 7 Jan 2011 19:09:08 -0800	[thread overview]
Message-ID: <AANLkTimO5-0aq7Vw2fP+Fka+Uo88ESBwLWav9fRdcZCZ@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=OKoLcLDCXacgXOa+nCST0oNt6_i4JKLbKMK7B@mail.gmail.com>

On Fri, Jan 7, 2011 at 6:00 PM, Jimmy Soho <jimmy.soho@gmail.com> wrote:
> Hi All,
>
> Having an akward noob moment... I have unicorn_rails (1.1.5) running
> with 2 workers, with rails 2.3.10 in development mode. In
> environment.rb at the bottom I have this line of code:
>
>    puts "#{Time.current} #{Thread.current.object_id}:
> #{Thread.current.keys.inspect}"
>
> In a simple controller I have this:
>
>   def index
>     puts "#{Time.current} #{Thread.current.object_id}:
> #{Thread.current.keys.inspect}"
>     sleep 5
>     puts "#{Time.current} #{Thread.current.object_id}:
> #{Thread.current.keys.inspect}"
>     render :text => "foo"
>   end
>
> In window 1 I tail log/unicorn.log.
> In windows 2 and 3 I start at about the same time:  curl http://localhost:3000
>
> The output is this:
>
> 2011-01-08 01:53:56 UTC 2148444460: [:__inspect_key__, :i18n_config,
> :__recursive_key__]
> worker=1 ready
> 2011-01-08 01:53:56 UTC 2148444460: [:__inspect_key__, :i18n_config,
> :__recursive_key__]
> worker=0 ready
> 2011-01-08 01:53:57 UTC 2148444460: [:__inspect_key__, :i18n_config,
> :__recursive_key__]
> 2011-01-08 01:53:59 UTC 2148444460: [:__inspect_key__, :i18n_config,
> :__recursive_key__]
> 2011-01-08 01:54:02 UTC 2148444460: [:__inspect_key__, :i18n_config,
> :__recursive_key__]
> 2011-01-08 01:54:04 UTC 2148444460: [:__inspect_key__, :i18n_config,
> :__recursive_key__]
>
> Looking at the timings the 2 requests seem to have been handled in
> parallel, as expected.
>
> However, the Thread.current value within those parallel requests is
> always the same.
>
> Are two separate requests not handled by different threads? How does that work??
>


Unicorn is a multi-process model with Inter-process communication -
more akin to a unix service - threads are not considered a wise
investment in the ruby community.

Worker1 / Worker0 are entirely separate processes - as is the master
unicorn process.

Review  Fork for more details.

http://en.wikipedia.org/wiki/Fork_(operating_system)
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

  parent reply	other threads:[~2011-01-08  3:42 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 ` Curtis j Schofield [this message]
2011-01-08  5:54   ` Thread.current Jimmy Soho
2011-01-11 22:52     ` Thread.current Jimmy Soho
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=AANLkTimO5-0aq7Vw2fP+Fka+Uo88ESBwLWav9fRdcZCZ@mail.gmail.com \
    --to=curtis.schofield@gmail.com \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://yhbt.net/unicorn.git/

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