[Twisted-Python] twisted.mail.relaymanager.MXCalculator.getMX in Win32 got problem

biziap biziap fetbiz at gmail.com
Fri Dec 12 19:46:07 EST 2008


The problem is that: the UDP listening ports increase rapidly and eventually
come to the end: too many open file in selector.
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).
In Linux, the listening UDP port keep only 1 instance no matter how many
lookups .
Try the script below:
------------------------------
from twisted.mail import relaymanager
from twisted.internet import reactor,defer

global MXC
MXC = relaymanager.MXCalculator()
def getMailExchange(host):
    global MXC
    def cbMX(mxRecord):
        print 'Got mxRecord: %s' % mxRecord.name
    return MXC.getMX(host).addCallback(cbMX)

def run():
    d = getMailExchange('gmail.com')
    def next(mxRecord):
        d = getMailExchange('yahoo.com')

    #d.addCallback(next)     ## uncomment the line to increase your UDP
listening ports as many as you want
reactor.callWhenRunning(run)
reactor.run()
--------------------------------------------------

Any hints?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20081213/1e6e985e/attachment.htm 


More information about the Twisted-Python mailing list