No luck Hemant. I changed my worker as follows, no error, I get the exact same o/p as before. Where might I be messing up?<div>Thanks!</div><div>Raghu<br><div>============================</div><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">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,:x =&gt; args[:job_key])</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">logger.info</a> &quot;*** FOO_WORKER/MY_ACTUAL_METHOD &quot; + args[:x] + &quot; 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><br><div class="gmail_quote">On Wed, Dec 31, 2008 at 2:43 PM, Raghu Srinivasan <span dir="ltr">&lt;<a href="mailto:raghu.srinivasan@gmail.com">raghu.srinivasan@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">No, I don&#39;t get any errors at all. Why is it mandatory for the method that I want to run concurrently to receive an argument? In the real case of course I&#39;ll be passing some equivalent of an ID but let me try with that and see...<div>
<div></div><div class="Wj3C7c"><br>
<br><div class="gmail_quote">On Wed, Dec 31, 2008 at 1:48 PM, hemant <span dir="ltr">&lt;<a href="mailto:gethemant@gmail.com" target="_blank">gethemant@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Could it be, because method that runs in thread expects an argument<br>
and you are not passing that argument when using thread_pool.defer()<br>
??<br>
<br>
Did you not get any errors in log file?<br>
<div><div></div><div><br>
<br>
<br>
On Wed, Dec 31, 2008 at 10:45 PM, Raghu Srinivasan<br>
&lt;<a href="mailto:raghu.srinivasan@gmail.com" target="_blank">raghu.srinivasan@gmail.com</a>&gt; wrote:<br>
&gt; I&#39;m on BDRB v 1.0.3 and am trying to understand how thread_pool and<br>
&gt; pool_size work. I have to kick of dozens of jobs on schedule (each hour or<br>
&gt; so). Other than the fact that they&#39;re all accessing the same DB there&#39;s no<br>
&gt; reason for them to not run in parallel. thread_pool/pool_size should be the<br>
&gt; way to go right?<br>
&gt; I&#39;ve put in sample code with its results below:<br>
&gt; My Rails controller kicks off 5 jobs in a loop - each calling the<br>
&gt; run_concurrent method in my foo worker. run_concurrent then calls<br>
&gt; my_actual_method which just logger.infos a message with a time stamp and<br>
&gt; sleeps for 5 seconds to simulate a long running job. I did this as<br>
&gt; per <a href="http://backgroundrb.rubyforge.org/workers/#thread_pool" target="_blank">http://backgroundrb.rubyforge.org/workers/#thread_pool</a> Since I&#39;m calling<br>
&gt; this via a defer and have a pool size of 10, I expect to see that<br>
&gt; my_actual_method actually gets called 5 times in quick succession (since the<br>
&gt; pool size is greater than the # of calls). However I find that<br>
&gt; run_concurrent doesn&#39;t even call my_actual_method. Here&#39;s the output from my<br>
&gt; backgroundrb log when I go to <a href="http://mysite.com/some/foobar" target="_blank">http://mysite.com/some/foobar</a><br>
&gt; Can someone help me understand what I&#39;m doing wrong here?<br>
&gt; Thanks,<br>
&gt; Raghu<br>
&gt; ====================================================<br>
&gt; Rails controller code<br>
&gt; class SomeController &lt; ApplicationController<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; def foobar<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = 0<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while i &lt; 5<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; worker = MiddleMan.worker(:foo_worker)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = worker.run_concurrent(:job_key =&gt;<br>
&gt; random_string(10))<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i += 1<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render :text =&gt; &#39;all done at &#39; + Time.now.to_s<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
&gt; end<br>
&gt; ====================================================<br>
&gt; Worker code<br>
&gt; class FooWorker &lt; BackgrounDRb::MetaWorker<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; set_worker_name :foo_worker<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; pool_size 10<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; def create<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # this method is called, when worker is loaded for the first<br>
&gt; time<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; def run_concurrent(args)<br>
&gt; &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; +<br>
&gt; Time.now.to_s<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thread_pool.defer(:my_actual_method)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; def my_actual_method(args)<br>
&gt; &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; +<br>
&gt; Time.now.to_s<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep 5<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
&gt; end<br>
&gt; ====================================================<br>
&gt; Here&#39;s the output<br>
&gt; # Logfile created on Wed Dec 31 09:15:21 +0000 2008 by /<br>
&gt; foo_worker started (pid:5087)<br>
&gt; Schedules for worker loaded (pid:5087)<br>
&gt; run_concurrent job_keydfvq5o4m0s (pid:5087)<br>
&gt; *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
&gt; run_concurrent job_keyy4tascam6k (pid:5087)<br>
&gt; *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
&gt; run_concurrent job_key8gw2eegeqs (pid:5087)<br>
&gt; *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
&gt; run_concurrent job_keyywb1oop73t (pid:5087)<br>
&gt; *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
&gt; run_concurrent job_key17gfkqtzjh (pid:5087)<br>
&gt; *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
&gt; ====================================================<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Backgroundrb-devel mailing list<br>
&gt; <a href="mailto:Backgroundrb-devel@rubyforge.org" target="_blank">Backgroundrb-devel@rubyforge.org</a><br>
&gt; <a href="http://rubyforge.org/mailman/listinfo/backgroundrb-devel" target="_blank">http://rubyforge.org/mailman/listinfo/backgroundrb-devel</a><br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Let them talk of their oriental summer climes of everlasting<br>
conservatories; give me the privilege of making my own summer with my<br>
own coals.<br>
<br>
<a href="http://gnufied.org" target="_blank">http://gnufied.org</a><br>
</font></blockquote></div><br>
</div></div></blockquote></div><br></div></div>