<br><br><div class="gmail_quote">On Feb 20, 2008 2:39 PM, hemant &lt;<a href="mailto:gethemant@gmail.com">gethemant@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Thu, Feb 21, 2008 at 1:02 AM, John Wells &lt;<a href="mailto:lists@sourceillustrated.com">lists@sourceillustrated.com</a>&gt; wrote:<br>&gt;<br>&gt;<br>&gt; On Feb 20, 2008 2:22 PM, hemant &lt;<a href="mailto:gethemant@gmail.com">gethemant@gmail.com</a>&gt; wrote:<br>
&gt; &gt; But later we changed the code and we thought when you invoke<br>&gt; &gt; delete_worker, your worker should exit immediately and request to kill<br>&gt; &gt; a worker shouldn&#39;t be queued.<br>&gt; &gt;<br>&gt; &gt; In current code, apart from executing &quot;delete_worker&quot; another way to<br>
&gt; &gt; kill workers is to call &quot;exit&quot; from inside of a worker. This will give<br>&gt; &gt; you opportunity to do proper cleanup and stuff.<br>&gt; &gt; I am not sure, if this is what you want, but &quot;delete_worker&quot; is like<br>
&gt; &gt; &quot;kill -9 &quot; of unix.<br>&gt; &gt;<br>&gt; &gt; So, if you want to handle graceful exit, call exit from worker code<br>&gt; itself.<br>&gt; &gt;<br>&gt;<br>&gt; Thanks for your reply.<br>&gt;<br>&gt; So how would I be able to signal to the worker that it should call exit? I<br>
&gt; guess that is the challenge. The worker is involved in a large batch job,<br>&gt; and I need to be able to send a message to it to tell it to kill itself. I<br>&gt; had hacked out an approach using both a database table in which it would<br>
&gt; check for the existence of a certain row, and if there remove and kill<br>&gt; itself, but I wondered if the framework itself provided a better way?<br>&gt;<br>&gt; Also, assuming I just continue to use delete_worker in the way I am today,<br>
&gt; is there any way possible to delete the last status the worker reported?<br>&gt;<br><br></div></div>Something like this:<br><br>class FooWorker &lt; BackgrounDRb::MetaWorker<br> &nbsp; &nbsp;def some_work(args = nil)<br> &nbsp; &nbsp; &nbsp; # do some job processing from database<br>
 &nbsp; &nbsp; &nbsp; exit<br> &nbsp; &nbsp; end<br>end</blockquote><div><br><br>Ok, but when would exit be called here? After all the work is done?<br><br>I guess what I want is a kill -9 functionality, but with the ability to at the very least clear the worker&#39;s status...<br>
</div></div>