[Backgroundrb-devel] Multiple copies of same worker

hemant gethemant at gmail.com
Mon Dec 17 10:03:15 EST 2007


> On Dec 17, 2007 3:40 PM, Danila Ulyanov <du at bestwaytech.com> wrote:
> > Hello!
> >
> > I remember there was a thread sometime last month about multiple copies
> > of the same worker. Is that still impossible to do?
> >
> > What I am trying to accomplish is to limit number of concurrent
> > connections for a lengthy search. I used to put search requests in a
> > queue, then as slots freed up, they spawned off a new copy of the
> > "search worker" which killed itself upon completion. That way no more
> > than 8 searches were conducted at the same time.
> >
> > Will it be possible to do this in the new version or is there an
> > alternative solution to this problem?
> >

Yes, you can have multiple copies of same worker running. But there
are two catches:

1. You have to specify a unique job_key for each worker, when you are
making a call to a start worker.
2. To start a worker, you will have to use
MiddleMan.new_worker(:worker => :foo_worker, :job_key => "whoa_man")

To exit a worker, once its done with search, simply call "exit" on them.

Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.


More information about the Backgroundrb-devel mailing list