# Long report

**URL:** <https://www.ruby-forum.com/t/long-report/92808>\
**Category:** Rails\
**Created:** [April 24, 2007, 1:33pm UTC](https://www.ruby-forum.com/t/long-report/92808 "2007-04-24T13:33:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 24, 2007, 1:33pm UTC](https://www.ruby-forum.com/t/long-report/92808/1 "2007-04-24T13:33:40Z")

</div>

Hi all!

I have a rails app that has the ability to export data to excel. The  
problem is that the report is very bug, so I need a way to reduce the  
waiting time of my clients.

My thought was, lunch some threads… but… is it safe in rails?

Thanks  
Pedro C.

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 24, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/long-report/92808/2 "2007-04-24T16:33:32Z")

</div>

Pedro C. wrote:

> Hi all!
> 
> I have a rails app that has the ability to export data to excel. The  
> problem is that the report is very bug, so I need a way to reduce the  
> waiting time of my clients.
> 
> My thought was, lunch some threads… but… is it safe in rails?
> 
> Thanks  
> Pedro C.

Nope. It is unsafe in rails. You should look into backgroundrb  
instead. It is very simple, you just need to create the proper worker  
tasks and start the worker tasks using Middleman. You may want to start  
the worker in background.

key = MiddleMan.new\_worker(:class =\> :excel\_worker)  
worker = MiddleMan.worker(key)  
worker.work\_thread(:method =\> ‘export\_data’, :args =\> params)

Note that backgroundrb will have to be running first.

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 24, 2007, 5:37pm UTC](https://www.ruby-forum.com/t/long-report/92808/3 "2007-04-24T17:37:31Z")

</div>

Thanks!

And that would be multi tasking right?

Wai T. wrote:

> Pedro C. wrote:
> 
> > Hi all!
> > 
> > I have a rails app that has the ability to export data to excel. The  
> > problem is that the report is very bug, so I need a way to reduce the  
> > waiting time of my clients.
> > 
> > My thought was, lunch some threads… but… is it safe in rails?
> > 
> > Thanks  
> > Pedro C.
> 
> Nope. It is unsafe in rails. You should look into backgroundrb  
> instead. It is very simple, you just need to create the proper worker  
> tasks and start the worker tasks using Middleman. You may want to start  
> the worker in background.
> 
> key = MiddleMan.new\_worker(:class =\> :excel\_worker)  
> worker = MiddleMan.worker(key)  
> worker.work\_thread(:method =\> ‘export\_data’, :args =\> params)
> 
> Note that backgroundrb will have to be running first.

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 24, 2007, 7:31pm UTC](https://www.ruby-forum.com/t/long-report/92808/4 "2007-04-24T19:31:38Z")

</div>

> I have a rails app that has the ability to export data to excel. The  
> problem is that the report is very bug, so I need a way to reduce the  
> waiting time of my clients.
> 
> My thought was, lunch some threads… but… is it safe in rails?

Pedro,

Backgroundrb ([http://backgroundrb.rubyforge.org/](http://backgroundrb.rubyforge.org/)) was designed to do  
exactly this. Check it out.

–  
Zack C.  
[http://depixelate.com](http://depixelate.com)

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 25, 2007, 2:15am UTC](https://www.ruby-forum.com/t/long-report/92808/5 "2007-04-25T02:15:20Z")

</div>

> I have a rails app that has the ability to export data to excel. The  
> problem is that the report is very bug, so I need a way to reduce the  
> waiting time of my clients.
> 
> My thought was, lunch some threads… but… is it safe in rails?

You might look into backgrounddrb… you could pass off the generating  
of  
the report to it and then have it update a flag in the database that the  
report is ready or send an email to the user with the url to download  
it…

-philip

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 25, 2007, 3:23am UTC](https://www.ruby-forum.com/t/long-report/92808/6 "2007-04-25T03:23:24Z")

</div>

The answer in RoR for long processes is BackgrounDRb

[http://backgroundrb.rubyforge.org/](http://backgroundrb.rubyforge.org/)

Sorry I don’t have more details. I haven’t yet worked with this  
myself. Maybe someone else can fill in the gaps in my knowledge.

What I’m interested in would be that when you send the task to  
BackgrounDRb process and you request-response cycle ends, how do you  
then provided feedback to the using that the process is complete? Is  
it possible to use AJAX to poll the long process for it’s status, or  
does the BackgroundDRb provide feedback in some form of callback  
mechanism?

I’m guessing the answers to these questions become obvious when  
working with BackgrounDRb, but I just don’t have those answers for you  
at this time.

On Apr 24, 7:33 am, Pedro C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [April 25, 2007, 11:45am UTC](https://www.ruby-forum.com/t/long-report/92808/7 "2007-04-25T11:45:31Z")

</div>

On 4/24/07, Pedro C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks!
> 
> And that would be multi tasking right?

Well not strictly true, there’s no requirement for BackgroundRb to be  
running on the  
same machine as Rails. Which is actually a strong advantage.

Though I am not sure if there is some platform sensitivity with Rails

- BackgroundRb  
on windows. I thought it was mentioned in the HOWTO on the rubyonrails  
site.

You might want to check.
