[Backgroundrb-devel] querying status of worker with job_key

hemant kumar gethemant at gmail.com
Tue Dec 18 12:12:40 EST 2007


On Tue, 2007-12-18 at 19:50 +0300, Ivan S. Manida wrote:
> Reynard wrote:
> > Is it possible to start a worker with job_key and then ask_status
> of that
> > specific worker with the job_key?
> >
> > MiddleMan.ask_work(:worker => :auth_worker, :job_key=>'1',
> > :worker_method => :auth)
> >
> > and then
> >
> > MiddleMan.ask_status(:worker => :auth_worker, :job_key=>'1')
> 
> 
> You should use register_status() from your worker - this works for
> me (using job_key as you describe). Of course, code is not yet well
> tested, but at least the status part is working fine :)

yes thats correct, before being able to query status of a worker, you
need to set the status object first and it will work afterwards.

For example:
class ErrorWorker < BackgrounDRb::MetaWorker
  set_worker_name :error_worker
  set_no_auto_load(true)

  def create(args = nil)
    logger.info "login worker started"
    register_status("Started")
  end
end

>> MiddleMan.new_worker(:worker => :error_worker, :job_key => "hello")
=> 71
>> MiddleMan.ask_status(:worker => :error_worker, :job_key => "hello")
=> "Started"

> 
> I have another problem - meta_pimp dies sometimes, in about 50% of
> the jobs. With the following stack trace. Worker is trivial but is
> using job_key. Looking through the code, it seems that connection is
> dropped while working, but which one - master <-> worker?
> 
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/meta_pimp.rb:58:in
> `process_response': undefined method `instance' for nil:NilClass
> (NoMethodError)
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/meta_pimp.rb:29:in
> `handle_object'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/meta_pimp.rb:20:in
> `receive_data'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:29:in
> `call'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:29:in
> `extract'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:42:in
> `extract'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/meta_pimp.rb:18:in
> `receive_data'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/packet_master.rb:63:in
> `handle_internal_messages'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/core.rb:154:in
> `start_reactor'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/core.rb:152:in
> `each'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/core.rb:152:in
> `start_reactor'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/core.rb:143:in
> `loop'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/core.rb:143:in
> `start_reactor'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/framework/packet_master.rb:20:in
> `run'
>         from
> /var/apps/ror_trunk/vendor/plugins/backgroundrb/server/master_worker.rb:133:in
> `initialize'
>         from script/backgroundrb:37:in `new'
>         from script/backgroundrb:37
> Some read error

Ok Ivan,

This is happening because, bdrb worker is trying to send data to rails,
even when rails has disconncted. It should be fixed now. Check it out.


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