@Frederick:

could you give me a configuration example in which the sleep doesn't 
block the process ? (rails threadsafe mode...)

I try with JRuby/Patched Mongrel/Glassfish gem but the result is evere 
the same: ex. 4 concurrent calls with sleep 10 each one I must wait 40 
seconds !

The simple example I try is this:

  def test
    @value = Time.now
    sleep 10
  end

The full example is this:

rails concurrent
cd concurrent
script/generate controller test test

edit app/controllers/test_controller.rb, modify source as follow:

class TestController < ApplicationController
  def test
    @value = Time.now
    sleep 10
  end
end

edit app/views/test/test.html.erb, modify source as follow:

<%= @value %>

edit config/environments/production.rb, uncomment last line as follow:

config.threadsafe!

edit config/environemt.rbm uncomment frameworks line as follow (no database, 
resource, mail support for this very simple test...):

config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

Now run:

jruby -S gfrake config

edit config/glassfish.yml, modify config as follow (notice 4 runtime instances 
!):

environment: production
jruby-runtime-pool:
initial: 4
min: 4
max: 4

And finally start glassfish gem:

jruby -S glassfish

Now, if you try to call 4 times (concurrently) the following url...

http://localhost:3000/test/test

...you must wait 40 seconds for the 4th response...

I try also with this configuration:

runtimes=>1
runtimes_min=>1
runtimes_max=>1

but I wait 40 seconds...

I try with "patched" mongrel but the time is the same...

Do you have an example of how to configure the system in which 4 
concurrent requests with sleep 10 can run in only 10 seconds ?
>
> On Sep 23, 1:27 pm, RVince <rvinc...@hotmail.com> wrote:
>   
>> I have something in my controller which needs to wait 1 or 2 seconds
>> before doing a "render ..."
>>     
>
> well you could call sleep, but you will of course block that mongrel/
> passenger instance etc. for the duration of the sleep (assuming rails
> in non threadsafe mode)
>
> Fred
>   
>> Is there a means in Ruby where I can make things wait by x seconds or
>> milliseconds before continuing processing a request? Thanks, RVince
>>     
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to