In the Twisted pseudo-sprint yesterday, I made some changes to the doc/names/examples/testdns.py and twisted/names/dns.py to clean up the deprecation warnings. Attached are two svn diffs of the changes made. I've run the trials for twisted names and everything passes with the exception of testIPv6. That was skipped since I'm not using IPv6 on my laptop. Would someone please review them and commit the changes to SVN? There's also a deprecation warning in twisted/names/client.py that I'll try to get to while at the pycon... Thanks. - Peter peter@think:/space/src/twisted/Twisted> svn diff doc/names/examples/testdns.py Index: doc/names/examples/testdns.py =================================================================== --- doc/names/examples/testdns.py (revision 13290) +++ doc/names/examples/testdns.py (working copy) @@ -1,9 +1,8 @@ #!/usr/bin/env python import sys -from twisted.names import client +from twisted.names import client, dns from twisted.internet import reactor -from twisted.protocols import dns r = client.Resolver('/etc/resolv.conf') @@ -27,6 +26,10 @@ if __name__ == '__main__': import sys + if len( sys.argv ) < 2: + print 'usage: testdns.py domain_name' + sys.exit( 1 ) + r.lookupAddress(sys.argv[1]).addCallback(gotAddress).addErrback(gotError) r.lookupMailExchange(sys.argv[1]).addCallback(gotMails).addErrback(gotError) r.lookupNameservers(sys.argv[1]).addCallback(gotNameservers).addErrback(gotError) peter@think:/space/src/twisted/Twisted> svn diff twisted/names/dns.py Index: twisted/names/dns.py =================================================================== --- twisted/names/dns.py (revision 13294) +++ twisted/names/dns.py (working copy) @@ -1086,7 +1086,8 @@ m = Message() m.fromStr(data) if self.liveMessages.has_key(m.id): - d = self.liveMessages[m.id] + d, timeout_call = self.liveMessages[m.id] + timeout_call.cancel( ) del self.liveMessages[m.id] # XXX we shouldn't need this hack of catching exceptioon on callback() try: @@ -1123,8 +1124,13 @@ self.resends[id] = 1 m = Message(id, recDes=1) m.queries = queries - d = self.liveMessages[id] = defer.Deferred() - d.setTimeout(timeout, self._clearFailed, id) + + from twisted.internet import reactor + d = defer.Deferred() + timeoutCall = reactor.callLater( + timeout, + lambda: d.called or self._clearFailed( d, id ) ) + self.liveMessages[id] = ( d, timeoutCall ) self.writeMessage(m, address) return d