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 < BackgrounDRb::MetaWorker</div>
<div><br></div><div> set_worker_name :foo_worker</div><div> pool_size 10</div><div><br></div><div> def create</div><div> # this method is called, when worker is loaded for the first time</div>
<div> end</div><div><br></div><div> def run_concurrent(args)</div><div> <a href="http://logger.info">logger.info</a> "*** FOO_WORKER/RUN_CONCURRENT at " + Time.now.to_s</div><div> thread_pool.defer(:my_actual_method,:x => args[:job_key])</div>
<div> end</div><div><br></div><div> def my_actual_method(args)</div><div> <a href="http://logger.info">logger.info</a> "*** FOO_WORKER/MY_ACTUAL_METHOD " + args[:x] + " at " + Time.now.to_s</div>
<div> sleep 5</div><div> 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"><<a href="mailto:raghu.srinivasan@gmail.com">raghu.srinivasan@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">No, I don'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'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"><<a href="mailto:gethemant@gmail.com" target="_blank">gethemant@gmail.com</a>></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>
<<a href="mailto:raghu.srinivasan@gmail.com" target="_blank">raghu.srinivasan@gmail.com</a>> wrote:<br>
> I'm on BDRB v 1.0.3 and am trying to understand how thread_pool and<br>
> pool_size work. I have to kick of dozens of jobs on schedule (each hour or<br>
> so). Other than the fact that they're all accessing the same DB there's no<br>
> reason for them to not run in parallel. thread_pool/pool_size should be the<br>
> way to go right?<br>
> I've put in sample code with its results below:<br>
> My Rails controller kicks off 5 jobs in a loop - each calling the<br>
> run_concurrent method in my foo worker. run_concurrent then calls<br>
> my_actual_method which just logger.infos a message with a time stamp and<br>
> sleeps for 5 seconds to simulate a long running job. I did this as<br>
> per <a href="http://backgroundrb.rubyforge.org/workers/#thread_pool" target="_blank">http://backgroundrb.rubyforge.org/workers/#thread_pool</a> Since I'm calling<br>
> this via a defer and have a pool size of 10, I expect to see that<br>
> my_actual_method actually gets called 5 times in quick succession (since the<br>
> pool size is greater than the # of calls). However I find that<br>
> run_concurrent doesn't even call my_actual_method. Here's the output from my<br>
> backgroundrb log when I go to <a href="http://mysite.com/some/foobar" target="_blank">http://mysite.com/some/foobar</a><br>
> Can someone help me understand what I'm doing wrong here?<br>
> Thanks,<br>
> Raghu<br>
> ====================================================<br>
> Rails controller code<br>
> class SomeController < ApplicationController<br>
> def foobar<br>
> i = 0<br>
> while i < 5<br>
> worker = MiddleMan.worker(:foo_worker)<br>
> result = worker.run_concurrent(:job_key =><br>
> random_string(10))<br>
> i += 1<br>
> end<br>
> render :text => 'all done at ' + Time.now.to_s<br>
> end<br>
> end<br>
> ====================================================<br>
> Worker code<br>
> class FooWorker < BackgrounDRb::MetaWorker<br>
> set_worker_name :foo_worker<br>
> pool_size 10<br>
> def create<br>
> # this method is called, when worker is loaded for the first<br>
> time<br>
> end<br>
> def run_concurrent(args)<br>
> <a href="http://logger.info" target="_blank">logger.info</a> "*** FOO_WORKER/RUN_CONCURRENT at " +<br>
> Time.now.to_s<br>
> thread_pool.defer(:my_actual_method)<br>
> end<br>
> def my_actual_method(args)<br>
> <a href="http://logger.info" target="_blank">logger.info</a> "*** FOO_WORKER/MY_ACTUAL_METHOD at " +<br>
> Time.now.to_s<br>
> sleep 5<br>
> end<br>
> end<br>
> ====================================================<br>
> Here's the output<br>
> # Logfile created on Wed Dec 31 09:15:21 +0000 2008 by /<br>
> foo_worker started (pid:5087)<br>
> Schedules for worker loaded (pid:5087)<br>
> run_concurrent job_keydfvq5o4m0s (pid:5087)<br>
> *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
> run_concurrent job_keyy4tascam6k (pid:5087)<br>
> *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
> run_concurrent job_key8gw2eegeqs (pid:5087)<br>
> *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
> run_concurrent job_keyywb1oop73t (pid:5087)<br>
> *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
> run_concurrent job_key17gfkqtzjh (pid:5087)<br>
> *** FOO_WORKER/RUN_CONCURRENT at Wed Dec 31 09:15:26 +0000 2008 (pid:5087)<br>
> ====================================================<br>
><br>
</div></div>> _______________________________________________<br>
> Backgroundrb-devel mailing list<br>
> <a href="mailto:Backgroundrb-devel@rubyforge.org" target="_blank">Backgroundrb-devel@rubyforge.org</a><br>
> <a href="http://rubyforge.org/mailman/listinfo/backgroundrb-devel" target="_blank">http://rubyforge.org/mailman/listinfo/backgroundrb-devel</a><br>
><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>