[Backgroundrb-devel] When does a worker terminate
Tuong.Le at Emulex.Com
Tuong.Le at Emulex.Com
Fri Feb 27 12:37:18 EST 2009
I think #exit is what I was looking for but all your feedback got me questioning whether I am using backgroundrb the right way, or the most optimized way. Please advise.
I was thinking of having my Rails app creating a new worker (Middleman.NEW_worker ...) EVERYTIME a time-consuming task is requested. As a result, I could have thousands of workers running at the same time. In my case, my Rails don't need to monitor the worker status, so I can just use #exit when a worker is done with its task.
Questions:
1. Should I create a new worker everytime like that? Or just having 1 worker, and call async_some_method() when I need to do some long running task? Is this where thread_pool come into place?
2. If I should create a new worker everytime, is there any reason why I shouldn't put the time-consuming task inside the worker's create() method?
3. At the Linux prompt, is there a way I can monitor how many workers are currently active?
Thank you everyone for your help.
Tuong
-----Original Message-----
From: hemant [mailto:gethemant at gmail.com]
Sent: Friday, February 27, 2009 12:18 AM
To: Raghu Srinivasan
Cc: Le, Tuong; backgroundrb-devel at rubyforge.org
Subject: Re: [Backgroundrb-devel] When does a worker terminate
On Fri, Feb 27, 2009 at 12:18 PM, Raghu Srinivasan
<raghu.srinivasan at gmail.com> wrote:
> Hemant - I thought that script/background start starts all workers
> and script/background stop stops all workers.
> How does one explicitly close/exit a particular worker from within Rails?
>
You can call #delete on worker. For example:
MiddleMan.worker("worker_name",<optional_worker_key>).delete
Or you can call #exit from within the worker.
More information about the Backgroundrb-devel
mailing list