<div>&gt; But I also learned that the return result is not just my string but a hash containing my string in the &quot;data&quot; hash member. </div>
<div>&nbsp;</div>
<div>That&#39;s useful for me to know because that&#39;s what was happening to me when I ported BackgrounDRb to Windows and I kept wondering if it was a bug on my side. But I guess that&#39;s what (the current version of) BackgrounDRb does on all platforms, so it&#39;s not just me. (I hadn&#39;t tried it on another platform because all I have for now is Windows.)</div>

<div>&nbsp;</div>
<div>- Brian</div>
<div><br><br>&nbsp;</div>
<div><span class="gmail_quote">On 4/18/08, <b class="gmail_sendername">Roggie Boone</b> &lt;<a href="mailto:rogboone@yahoo.com">rogboone@yahoo.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Yes, thank you!&nbsp; I had read about the optional 2nd argument<br>but misunderstood its usefulness.&nbsp; It&#39;s working now.&nbsp; But I also<br>
learned that the return result is not just my string but a hash<br>containing my string in the &quot;data&quot; hash member. <br><br>Rog 
<div><span class="e" id="q_119632c5ad861131_1"><br><br><b><i>Brian Morearty &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:brian@morearty.org" target="_blank">brian@morearty.org</a>&gt;</i></b> wrote: 
<blockquote style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">
<div>Sorry, I meant to reply-all. Here&#39;s what I wrote:</div>
<div>&nbsp;</div>
<div>Hello Rogelio,<br>&nbsp;<br>If you want a return value you have to call it synchronously. The default call is asynchronous--because after all, it&#39;s a background call. That&#39;s why you&#39;re getting nil back.<br>&nbsp;<br>
To make a synchronous call, pass &quot;true&quot; as the 2nd argument to your worker:<br>&nbsp;<br>&nbsp;res = MiddleMan.worker(:pdfmaker_worker, jk).getres(nil, true)<br>&nbsp;<br>In this example I used nil for the first argument because your getres function doesn&#39;t take an argument.<br>
&nbsp;<br>For more info see <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://backgroundrb.rubyforge.org/rails/index.html" target="_blank">http://backgroundrb.rubyforge.org/rails/index.html</a> and read the section &quot;Invoke a method on worker and get results.&quot;<br>
&nbsp;<br>- Brian Morearty<br>&nbsp;</div>
<div><br><br>&nbsp;</div>
<div class="gmail_quote">On Fri, Apr 18, 2008 at 11:07 AM, Roggie Boone &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rogboone@yahoo.com" target="_blank">rogboone@yahoo.com</a>&gt; wrote:<br>

<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hi,<br><br>I&#39;m new to BackgroundRB and am having some trouble figuring<br>out what must be a simple thing.&nbsp; I&#39;m in&nbsp; time crunch where I<br>
need my Rails app to generate PDF files on the fly for my website<br>users.&nbsp; But before I leap into that, I&#39;m trying to get familiar with<br>the basics.&nbsp; So I have this worker in my rails app lib/worker folder:<br>==============<br>
class PdfmakerWorker &lt; BackgrounDRb::MetaWorker<br>&nbsp; set_worker_name :pdfmaker_worker<br>&nbsp; set_no_auto_load(true)<br>&nbsp; def create(args = nil)<br>&nbsp;&nbsp;&nbsp; # this method is called, when worker is loaded for the first time<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; register_status(:cnt =&gt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.upto 100000000 do |x|<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x % 1000 == 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; register_status(:cnt =&gt; x)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; #exit<br>&nbsp; end<br><br>&nbsp; def getres<br>&nbsp;&nbsp;&nbsp; res = &quot;Just a test&quot;<br>
&nbsp;&nbsp;&nbsp; return res<br>&nbsp; end<br>end<br><br>============================================================<br><br>I&#39;ve written a simple program to test that worker and it is as follows:<br><br>jk = MiddleMan.new_worker(:worker =&gt; :pdfmaker_worker, :job_key =&gt; &quot;123&quot;, :data =&gt; nil)<br>
<br>sleep (5)<br><br>count = 0<br><br>while count &lt; 1 <br>&nbsp; pct = MiddleMan.ask_status(:worker =&gt; :pdfmaker_worker, :job_key =&gt; jk)<br>&nbsp; sleep(2)<br>&nbsp; puts &quot;Count is: &quot; + (pct[:cnt]).to_s<br>&nbsp; <br>&nbsp; res = MiddleMan.worker(:pdfmaker_worker, jk).getres<br>
&nbsp; puts &quot;Res is: &quot; + res.to_s<br>end<br>============================================================<br><br>I run script/console and load the above program.&nbsp; The worker counts up<br>to 10000000 and my little test program repeatedly queries the worker<br>
and writes &quot;Count is &lt;whatever&gt;&quot; to the screen as it should.<br><br>However, when it get to my custom method &quot;getres&quot; in the last<br>two lines of the test program,&nbsp; the return result for &quot;res&quot; is nil.&nbsp; The worker doesn&#39;t crash, it just appears not to return a result.&nbsp; I&#39;m sure it&#39;s<br>
something simple, but I don&#39;t see why.&nbsp; <br><br>Here is a sample output of one iteration of the simple program:<br>================<br>Count is: 970000000<br>{:type=&gt;:do_work, :worker=&gt;:pdfmaker_worker, :worker_method=&gt;:getres, :job_key=&gt;&quot;123&quot;}<br>
Res is: <br>{:type=&gt;:get_status, :worker=&gt;:pdfmaker_worker, :job_key=&gt;&quot;123&quot;}<br>================<br><br>It looks like the call to &quot;getres&quot; is being recognized, but I&#39;m obviously<br>missing some critical link.<br>
<br>My setup:<br><br>Ubuntu 7.10<br>Ruby 1.8.6<br>Rails 2.0.2<br>BackgroundRB (been through several versions, latest of <br>which was retrieved via svn on 4/17/08 and I updated the<br>backgroundrb script as per install guidelines)<br>
<br>Thanks in advance for your help.<br><br>Rogelio<br>
<div><br>
<div></div>
<hr size="1">
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ" target="_blank">Try it now.</a> 
<div></div>
<div></div></div><br>_______________________________________________<br>Backgroundrb-devel mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Backgroundrb-devel@rubyforge.org" target="_blank">Backgroundrb-devel@rubyforge.org</a><br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://rubyforge.org/mailman/listinfo/backgroundrb-devel" target="_blank">http://rubyforge.org/mailman/listinfo/backgroundrb-devel</a><br></blockquote></div>
<br><br clear="all"><br>-- <br>Brian </blockquote><br>
<p>
<hr size="1">
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ" target="_blank">Try it now.</a> 
<p></p></p></span></div></blockquote></div><br><br clear="all"><br>-- <br>Brian