Sleep blocking other users


#1

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/


#2

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/

#3

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/