Thanks for all the help.  We&#39;re going with addSystemEventTrigger for now, but we&#39;ll keep twistd in mind for future work.<div><br>Jason<br><br><div class="gmail_quote">On Fri, Feb 11, 2011 at 1:51 PM, Glyph Lefkowitz <span dir="ltr">&lt;<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><br>
On Feb 11, 2011, at 11:55 AM, <a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a> wrote:<br>
<br>
&gt; On 03:59 pm, <a href="mailto:jrennie@gmail.com">jrennie@gmail.com</a> wrote:<br>
&gt;&gt; On Fri, Feb 11, 2011 at 10:01 AM, &lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt; wrote:<br>
&gt;&gt;&gt; On Python 2.5 and earlier you won&#39;t be able to get Twisted&#39;s SIGCHLD<br>
&gt;&gt;&gt; handler using signal.getsignal.<br>
&gt;&gt;<br>
&gt;&gt; We&#39;re also moving to python 2.6 (the change is really Debian 5 to<br>
&gt;&gt; Debian 6).<br>
&gt;&gt; Should it would work in 2.6?<br>
&gt;<br>
&gt; I think so.<br>
&gt;&gt;<br>
&gt;&gt;&gt; What sort of things do your signal handlers do?<br>
&gt;&gt;<br>
&gt;&gt; IIRC, the main thing is to shut down the web server (cherrypy) we&#39;re<br>
&gt;&gt; running<br>
&gt;&gt; in parallel with twisted.  We also have some disk-caching for stateful<br>
&gt;&gt; signals which needs to ensure the cache file is up-to-date.<br>
&gt;<br>
&gt; For shutdown-type things, reactor.addSystemEventTrigger(phase,<br>
&gt; &#39;shutdown&#39;, f) might be better than getting into signal handlers (where<br>
&gt; phase is &#39;before&#39;, &#39;during&#39;, or &#39;after&#39;).<br>
<br>
<br>
</div>There&#39;s already a system event trigger already hooked up to the reactor: your main service&#39;s stopService call.  If your cherrypy webserver is wrapped up in an IService implementation in the service hierarchy constructed in your twistd plugin or tac file, you can just implement &#39;stopService&#39; and not do any manual registration with event triggers.  This is really a better way to go in general, as it&#39;s easier for other API consumers to deal with such an object than using the global broadcasting mechanism in the reactor.<br>

<br>
If you do want to manually add your own system event trigger, in most interesting cases you&#39;ll need to use the &#39;before&#39; phase.  During &#39;before&#39;, Deferreds returned by event triggers are respected (i.e. the reactor keeps running as long as they haven&#39;t fired).  If you schedule one for &#39;during&#39; or &#39;after&#39;, the event trigger really needs to do all of its work and complete it immediately (i.e. before returning).<br>

<div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jason Rennie<br>Research Scientist, ITA Software<br>617-714-2645<br><a href="http://www.itasoftware.com/">http://www.itasoftware.com/</a><br><br>
</div>