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"><<a href="mailto:ntoper@gmail.com">ntoper@gmail.com</a>></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"><<a href="mailto:tom.sheffler@gmail.com" target="_blank">tom.sheffler@gmail.com</a>></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's multiprocessing with Twisted and things are working nicely. I thought I'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="'courier new', monospace">class MultiprocessingStopService(Service):</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"> def stopService(self):</font></div>
<div><font face="'courier new', monospace"> import multiprocessing</font></div><div><font face="'courier new', monospace"> for p in multiprocessing.active_children():</font></div><div><font face="'courier new', monospace"> p.terminate()</font></div>
<div><font face="'courier new', 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="'courier new', monospace">s = MultiService()</font></div>
</div><div><font face="'courier new', monospace"> stopper = MultiprocessingStopService()</font></div><div><font face="'courier new', 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>