Hi Tom<br><br>  Does it work for windows? I use ampoule instead to manage multiple process.<br><br>Regards<br><br>gelin yan<br><br><div class="gmail_quote">On Sat, Jan 21, 2012 at 12:09 AM, Nicolas Toper <span dir="ltr">&lt;<a href="mailto:ntoper@gmail.com">ntoper@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">Hi Tom,<div><br></div><div>How do you pass data between the parent and its children with multiprocessing? It worked fine with Twisted in debug but never in prod :(</div>
<div><br></div><div>Best</div><div>Nicolas<br clear="all">
<br><br><div class="gmail_quote"><div><div class="h5">On Wed, Jan 18, 2012 at 6:39 PM, Tom Sheffler <span dir="ltr">&lt;<a href="mailto:tom.sheffler@gmail.com" target="_blank">tom.sheffler@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
We are using Py2.6&#39;s multiprocessing with Twisted and things are working nicely.  I thought I&#39;d pass on something that seems to work pretty well.  Comments welcome.<div><br></div><div>I am using multiprocessing to spawn long-running worker processes as children of Twisted.  When Twisted is killed, I want the children to be unceremoniously killed as well.  I looked into signal handlers, but creating a service that kills the child processes ended up being simpler and is working well with twistd daemonization.</div>


<div><br></div><div><div><font face="&#39;courier new&#39;, monospace">class MultiprocessingStopService(Service):</font></div><div><font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace">    def stopService(self):</font></div>


<div><font face="&#39;courier new&#39;, monospace">        import multiprocessing</font></div><div><font face="&#39;courier new&#39;, monospace">        for p in multiprocessing.active_children():</font></div><div><font face="&#39;courier new&#39;, monospace">            p.terminate()</font></div>


<div><font face="&#39;courier new&#39;, monospace">        Service.stopService(self)</font></div></div><div><br></div><div>and in my main service maker:</div><div><br></div><div><div>        <font face="&#39;courier new&#39;, monospace">s = MultiService()</font></div>


</div><div><font face="&#39;courier new&#39;, monospace">    stopper  = MultiprocessingStopService()</font></div><div><font face="&#39;courier new&#39;, monospace">    stopper.setServiceParent(s)</font></div><div><br></div>


<div>Perhaps this will be helpful to someone.</div><span><font color="#888888"><div><br></div><div>-T</div><div><br></div>
</font></span><br></div></div>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">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>
<br></blockquote></div><br></div>
<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>
<br></blockquote></div><br>