Forum: Ruby on Rails Sleep blocking other users.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David H. (Guest)
on 2007-01-24 19:23
Hi, I've got a method that requires me to sleep for a couple of seconds.

The problem is that all other requests are help up, waiting for this to
finish.

Is there a way to block just this request without impacting other
requests?

I tried
Thread.start() {
sleep 10
@myobject.reload
}
render :xml => @myobject.to_xml

Which makes it not block, but then the user can't see the results of the
reload.



I'm looking at some packages like this, but I'm not sure if this is the
right approach.
  http://backgroundrb.rubyforge.org/
unknown (Guest)
on 2007-01-24 19:52
(Received via mailing list)
On 1/24/07, David H. <removed_email_address@domain.invalid> wrote:
> Hi, I've got a method that requires me to sleep for a couple of seconds.
>
> The problem is that all other requests are help up, waiting for this to
> finish.
>
> Is there a way to block just this request without impacting other
> requests?

Two suggestions:

a) Multiple Rails processes behind a load-balancing reverse proxy.

b) Run the blocking task in the background and provide a way for the
browser to refresh status (for example, timed refresh of status div via
javascript):

    http://www.yup.com/articles/2006/05/23/
        handling-rails-background-and-batch-jobs-with-backgrounddrb
    http://backgroundrb.rubyforge.org/
David H. (Guest)
on 2007-01-24 20:37
Though viewable from a browser, it's not intended as such.

It sounds like I'll have to stick to something I was hoping to avoid.

Return a unique ID in the XML that's returned from the GET request
And provide a second address to check for status changes.

Eventually I'll be using a load-balancing proxy, perhaps that might be
the way to go.


unknown wrote:
> On 1/24/07, David H. <removed_email_address@domain.invalid> wrote:
>> Hi, I've got a method that requires me to sleep for a couple of seconds.
>>
>> The problem is that all other requests are help up, waiting for this to
>> finish.
>>
>> Is there a way to block just this request without impacting other
>> requests?
>
> Two suggestions:
>
> a) Multiple Rails processes behind a load-balancing reverse proxy.
>
> b) Run the blocking task in the background and provide a way for the
> browser to refresh status (for example, timed refresh of status div via
> javascript):
>
>     http://www.yup.com/articles/2006/05/23/
>         handling-rails-background-and-batch-jobs-with-backgrounddrb
>     http://backgroundrb.rubyforge.org/
This topic is locked and can not be replied to.