[Backgroundrb-devel] Getting started
Richard Everhart
rich.everhart at gmail.com
Thu Feb 14 20:41:34 EST 2008
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!
Rich
On Thu, Feb 14, 2008 at 3:24 PM, hemant <gethemant at gmail.com> wrote:
> On Fri, Feb 15, 2008 at 4:15 AM, Richard Everhart
>
> <rich.everhart at gmail.com> wrote:
>
> > Thanks, Hemant. I made the change related to the job key and I'm not
> > getting a value back from new_worker. However, the 'not able to
> > connect error' is on going.
> >
> > My zipped up app is attached. Thanks for helping me out.
> >
>
> First Problems with your controller code:
>
> You have line:
>
>
> session[:job_key] = MiddleMan.new_worker(:class => :fibonacci_worker,
> :job_key => 'the_key', :data => params[:input])
>
> Please note that, it should be :worker not :class, so please change the line to:
> session[:job_key] = MiddleMan.new_worker(:worker =>
> :fibonacci_worker, :job_key => 'the_key', :data => params[:input])
>
> Now, You have line:
>
>
> MiddleMan.send_request(:worker => :fibonacci_worker, :worker_method
> => :do_work, :data => params[:input])
>
> Again, as i said earlier, when you are creating a worker with a
> "job_key" you *must* always access that instance of worker with the
> same job key and hence it should be:
>
>
> MiddleMan.send_request(:worker => :fibonacci_worker, :worker_method
> => :do_work, :data => params[:input], :job_key => session[:job_key])
>
> Your worker code is perfectly fine and should work as it. Also, update
> your plugin from trunk and remove "backgroundrb" script present in
> script directory and restart the server and try now. It will work.
>
>
> --
> Let them talk of their oriental summer climes of everlasting
> conservatories; give me the privilege of making my own summer with my
> own coals.
>
> http://gnufied.org
>
More information about the Backgroundrb-devel
mailing list