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;"> global MXC</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def cbMX(mxRecord):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> print 'Got mxRecord: %s' % mxRecord.name </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 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;"> d = getMailExchange('<a href="http://gmail.com">gmail.com</a>')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> def next(mxRecord):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> d = getMailExchange('<a href="http://yahoo.com">yahoo.com</a>')<br>
<br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> #d.addCallback(next) </span><span style="font-family: courier new,monospace;"> ## 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>