[Backgroundrb-devel] Getting started
hemant
gethemant at gmail.com
Fri Feb 15 12:58:33 EST 2008
On Fri, Feb 15, 2008 at 7:11 AM, Richard Everhart
<rich.everhart at gmail.com> wrote:
> Changing 'class' to 'worker' in new_worker seemed to get things going.
> I can see that after new_worker is called the worker's create method
> is then called. This only seems to work once. After the first time, I
> get the following error:
>
> You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.send_request
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/framework/packet_master.rb:43:in
> `ask_worker'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/server/master_worker.rb:76:in
> `process_work'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/server/master_worker.rb:34:in
> `receive_data'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:29:in
> `call'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:29:in
> `extract'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/server/master_worker.rb:30:in
> `receive_data'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/framework/core.rb:195:in
> `read_external_socket'
> /home/reverhart/drb_test/vendor/plugins/backgroundrb/framework/core.rb:187:in
> `handle_external_messages'
> [...snip...]
>
> Eventually, what I would really like to do is return a value back to
> the browser. send_request is documented to do this but the browser
> just hangs and I really can't tell if the the worker method (do_work
> in this is being executed). While the work is being executed by the
> worker I'd like to display a progress bar or a busy indicator, both of
> which I've seen examples. But, it seems that the do_work method is
> never called, even when calling ask_work, which is not supposed to
> block.
>
> I have not tried out the latest version so I'm not sure if that will
> change things. Thanks a lot!
>
I wanted to ask, are you sure you want to create new workers on each
request? Can't you handle all the requests in the same instance of
worker. Also, send_request blocks until bdrb returns a response and
thats why your browser is hung.
A better approach is to use register_status in your worker and invoke
ask_status in rails code. Again, please read the README carefully from
start to beginning.
Also, use following links for debugging:
http://gnufied.org/2008/02/12/backgroundrb-best-practises/
http://www.johnyerhot.com/2008/02/11/debugging-backgroundrb/
More information about the Backgroundrb-devel
mailing list