[Backgroundrb-devel] 1) Error 2) sending request to a specific worker

hemant gethemant at gmail.com
Sat Dec 15 17:43:32 EST 2007


On Dec 16, 2007 3:38 AM, Mickael Faivre-Macon <faivrem at gmail.com> wrote:
> Hello !
>
> 1) I have this error logged by bdrb:
> undefined method `send_request' for nil:NilClass
> framework/packet_master.rb:58:in `ask_worker'
> backgroundrb/server/master_worker.rb:59:in `process_work'
> backgroundrb/server/master_worker.rb:16:in `receive_data'
> backgroundrb/framework/bin_parser.rb:29:in `call'
> backgroundrb/framework/bin_parser.rb:29:in `extract'
> backgroundrb/server/master_worker.rb:12:in `receive_data'
> backgroundrb/framework/core.rb:191:in `read_external_socket'
> backgroundrb/framework/core.rb:183:in `handle_external_messages'
> backgroundrb/framework/core.rb:156:in `start_reactor'
> backgroundrb/framework/core.rb:152:in `each'
> backgroundrb/framework/core.rb:152:in `start_reactor'
> backgroundrb/framework/core.rb:144:in `loop'
> backgroundrb/framework/core.rb:144:in `start_reactor'
> backgroundrb/framework/packet_master.rb:20:in `run'
> backgroundrb/server/master_worker.rb:115:in `initialize'
> ./script/backgroundrb:39:in `new'
> ./script/backgroundrb:39
>
> my code is :
>
> class MyController < ApplicationController
>
>   def index
>   end
>
>   def login
>     @worker = MiddleMan.new_worker(:worker => :xmpp_worker, :job_key => :my_key)
>     MiddleMan.ask_work(:worker => :xmpp_worker, :worker_method =>
> :login, :data => "test")
>     render(:partial=>'window')
>   end
>
> end
>
> class XmppWorker < BackgrounDRb::MetaWorker
>   set_worker_name :xmpp_worker
>   set_no_auto_load true
>
>   def create(args = nil)
>   end
>
>   def login
>   end
>
> end
>
> Can someone helps me ?
>
> 2) I am creating a worker with a key : MiddleMan.new_worker(:worker =>
> :xmpp_worker, :job_key => :my_key)
> Is it possible to use this key in a request to send work to a specific worker ?
>

I suggest you remove set_no_auto_load(true). Why exactly, you don't
want worker to be automatically loaded when bdrb starts?

The problem as i see may be because, since new_worker forks new worker
in separate process, but the worker is not available immediately and
hence you get the error.

If you insist on using dynamically starting workers, I will be see
what can be done to prevent error. There are couple of options.


-- 
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