search for: instantiate_worker

Displaying 2 results from an estimated 2 matches for "instantiate_worker".

2006 Jul 03
6
Req: Workers as singletons
...end end return nil end def new_singleton_worker(opts={}) @mutex.synchronize { worker = get_worker_by_class(opts[:class]) if worker.nil? job_key = opts[:job_key] || gen_key unless self[job_key] self[job_key] = instantiate_worker(opts[:class]).new(opts [:args]) return job_key else raise "job_key: #{job_key} already refers to a running worker" end else return worker end } end First the jobs array is checked if an instance o...
2006 Jun 28
1
How to add some process control...
...ted. This is because the instance functions I added to BackgrounDrb::Rails don''t seem to be available when kicked off from BackgrounDRb::Rails.initialize() def new_worker(opts={}) @mutex.synchronize { job_key = opts[:job_key] || gen_key unless self[job_key] self[job_key] = instantiate_worker(opts[:class]).new(job_key,opts[:args]) self[job_key].start_process return job_key else raise ::BackgrounDRbDuplicateKeyError end } end In MiddleMan::delete_worker(), I''ve added steps where, if the job is still alive, activate the kill signal to the job, and wai...