[Twisted-Python] Still fighting "twisted.names.client"

Jean-Paul Calderone exarkun at divmod.com
Tue Jan 24 12:34:59 EST 2006

On Tue, 24 Jan 2006 17:50:55 +0100, Jesus Cea <jcea at argo.es> wrote:
>Hash: SHA1
>I started a thread a month ago, with no luck yet.
>I have a reduced test case, for ease diagnosis. I hope Jean-Paul
>Calderone can have a look at the issue.

Thanks for following up on this.  I couldn't reproduce the problem before, but with your new example I can.

>===== File "dns4.py" =====
>class resolution(object) :
>  def __init__(self,domain) :
>    global myResolver
>    d = myResolver.lookupMailExchange(domain,timeout=(5,))

Here, you're specifying that the lookup should use no retransmits, and should fail if no response is received after 5 seconds.  This isn't generally a good way to do DNS lookups, but IIRC you had a particular reason for wanting this.  In any case, the first bug you hit was one that caused the first message received in response to the first query made on a resolver object to be spuriously dropped.  Since most applications do re-transmits, this usually didn't cause anything more problematic than one extra DNS request/response.  I've fixed this in current trunk.

>    d.addCallbacks(self._cbMailExchange, None)
>  def _cbMailExchange(self,results):
>    # Callback for MX query
>    print "XX",repr(results)
>    from twisted.internet import reactor
>    reactor.stop()
>    return

It turns out there is a bug in Twisted's UDP support.  Calling reactor.stop() from beneath datagramReceived() triggers an infinite exception loop.  I've created a ticket in the tracker (1448) for this.  Until it's resolved, or if you want this to work on a previous release of Twisted, you can use "reactor.callLater(0, reactor.stop)" to avoid the problem.

>from twisted.application import service
>class DomainResolver(service.Service):
>  def startService(self) :
>    global myResolver
>    from twisted.names import client
>    myResolver=client.Resolver(servers=[('', 53)])
>    resolution("argo.es")
>    #resolution("argo.es")
> [snip]
>Thanks in advance for your time.

Thanks for the minimal example :)


More information about the Twisted-Python mailing list