<div>I&#39;m on BDRB v 1.0.3 and am trying to understand how thread_pool and pool_size work. I have to kick of dozens of jobs on schedule (each hour or so). Other than the fact that they&#39;re all accessing the same DB there&#39;s no reason for them to not run in parallel. thread_pool/pool_size should be the way to go right?</div>

<div><br></div><div>I&#39;ve put in sample code with its results below:</div><div><br></div><div>My Rails controller kicks off 5 jobs in a loop - each calling the run_concurrent method in my foo worker. run_concurrent then calls my_actual_method which just logger.infos a message with a time stamp and sleeps for 5 seconds to simulate a long running job. I did this as per&nbsp;<a href="http://backgroundrb.rubyforge.org/workers/#thread_pool">http://backgroundrb.rubyforge.org/workers/#thread_pool&nbsp;</a>Since I&#39;m calling this via a defer and have a pool size of 10, I expect to see that my_actual_method actually gets called 5 times in quick succession (since the pool size is greater than the # of calls). However I find that run_concurrent doesn&#39;t even call my_actual_method. Here&#39;s the output from my backgroundrb log when I go to <a href="http://mysite.com/some/foobar" target="_blank">http://mysite.com/some/foobar</a></div>
<div><br></div><div>Can someone help me understand what I&#39;m doing wrong here?</div><div><br>Thanks,</div><div><br>Raghu</div>
<div><div>====================================================<br></div><div><span class="Apple-style-span" style="font-weight: bold;"><span class="Apple-style-span" style="background-color: rgb(255, 255, 51);">Rails controller code</span></span></div>
</div>
<div>class SomeController &lt; ApplicationController</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;def foobar</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i = 0</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while i &lt; 5</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;worker = MiddleMan.worker(:foo_worker)</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result = worker.run_concurrent(:job_key =&gt; random_string(10))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i += 1</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;render :text =&gt; &#39;all done at &#39; + Time.now.to_s</div>

<div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div>end</div><div>====================================================</div><div><span class="Apple-style-span" style="font-weight: bold;"><span class="Apple-style-span" style="background-color: rgb(255, 255, 51);">Worker code</span></span></div>
<div>class FooWorker &lt; BackgrounDRb::MetaWorker</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;set_worker_name :foo_worker</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pool_size 10</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;def create</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# this method is called, when worker is loaded for the first time</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;def run_concurrent(args)</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://logger.info" target="_blank">logger.info</a> &quot;*** FOO_WORKER/RUN_CONCURRENT at &quot; + Time.now.to_s</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;thread_pool.defer(:my_actual_method)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div>
<div>
<br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;def my_actual_method(args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://logger.info" target="_blank">logger.info</a> &quot;*** FOO_WORKER/MY_ACTUAL_METHOD at &quot; + Time.now.to_s</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sleep 5</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end</div><div>end</div><div><div>====================================================</div><div><div><div><span class="Apple-style-span" style="font-weight: bold;"><span class="Apple-style-span" style="background-color: rgb(255, 255, 51);">Here&#39;s the output</span></span></div>
<div># Logfile created on Wed Dec 31 09:15:21 +0000 2008 by /<br></div><div><div>foo_worker started (pid:5087)</div><div>Schedules for worker loaded (pid:5087)</div><div>run_concurrent job_keydfvq5o4m0s (pid:5087)</div><div>
*** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)</div><div>run_concurrent job_keyy4tascam6k (pid:5087)</div><div>*** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)</div><div>
run_concurrent job_key8gw2eegeqs (pid:5087)</div><div>*** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)</div><div>run_concurrent job_keyywb1oop73t (pid:5087)</div><div>*** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)</div>
<div>run_concurrent job_key17gfkqtzjh (pid:5087)</div><div>*** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)</div><div><div>====================================================</div><div><br></div>
<div></div></div></div></div></div></div>