The problem is that: the UDP listening ports increase rapidly and eventually come to the end: too many open file in selector.<br>As many as the hosts you lookup, those UDP ports are still alive. It is very different from running this script in Linux (gentoo 2.6).<br>
In Linux, the listening UDP port keep only 1 instance no matter how many lookups .<br>Try the script below:<br>------------------------------<br><span style="font-family: courier new,monospace;">from twisted.mail import relaymanager</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">from twisted.internet import reactor,defer</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">global MXC</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MXC = relaymanager.MXCalculator()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def getMailExchange(host):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; global MXC</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; def cbMX(mxRecord):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;Got mxRecord: %s&#39; % mxRecord.name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; return MXC.getMX(host).addCallback(cbMX)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def run():</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; d = getMailExchange(&#39;<a href="http://gmail.com">gmail.com</a>&#39;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; def next(mxRecord):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d = getMailExchange(&#39;<a href="http://yahoo.com">yahoo.com</a>&#39;)<br>
<br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; #d.addCallback(next) </span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; ## uncomment the line to increase your UDP listening ports as many as you want</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">reactor.callWhenRunning(run)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">reactor.run()<br>--------------------------------------------------<br>
<br>Any hints? <br></span>