[Twisted-Python] twisted-names: Cryptic error with no traceback?
![](https://secure.gravatar.com/avatar/d4828a232f930a0ef907e1d314fbc993.jpg?s=120&d=mm&r=g)
Some users of a program that I'm writing have been reporting this error that I so far have been unable to track down. It seems that it originates from Twisted, but that it skips around my errback handler, and provides no traceback information: Traceback (most recent call last): Failure: twisted.names.error.DNSQueryTimeoutError: My query is made from line 121 here: http://dtella.svn.sourceforge.net/viewvc/dtella/tags/1.0.2/dtella_dnslookup.py?revision=406&view=markup Does anyone have any insight as to where this error could be coming from, and why it isn't getting trapped by my errback function? I don't know yet whether this is a problem in Twisted, or if I'm doing something incorrect in my err_cb.
![](https://secure.gravatar.com/avatar/d4828a232f930a0ef907e1d314fbc993.jpg?s=120&d=mm&r=g)
On 2/27/07, Paul Marks <pmarks@purdue.edu> wrote:
Update: Yay, I finally found the bug! Turns out it's a problem in Twisted. Inside DNSDatagramProtocol.writeMessage, it writes to the UDP socket, and never checks for socket.error. If a socket.error does occur, then the query() function blows up instead of returning its deferred. So, cancelCall gets forgotten. A few seconds later, it chucks a DNSQueryTimeoutError, and the deferred gets garbage collected without anything handling it. The solution, I think, is this: - in query(), move the "self.writeMessage(m, address)" call up a few lines, to before the Deferred and callLater are created. - Trap socket.error when making this writeMessage call. If it catches one, return a defer.fail() immediately. Basically, if the UDP packet fails to be sent, then the timeout should never be created.
![](https://secure.gravatar.com/avatar/d4828a232f930a0ef907e1d314fbc993.jpg?s=120&d=mm&r=g)
On 2/27/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
Actually, I was having 2 separate issues; one was the non-handling of the socket.error, which was obvious after seeing the traceback. The other was the mysterious DNSQueryTimeoutError that I started this thread about. I filed that ticket before I realized that one was actually causing the other, but it all seems to make sense now.
![](https://secure.gravatar.com/avatar/d4828a232f930a0ef907e1d314fbc993.jpg?s=120&d=mm&r=g)
On 2/27/07, Paul Marks <pmarks@purdue.edu> wrote:
Update: Yay, I finally found the bug! Turns out it's a problem in Twisted. Inside DNSDatagramProtocol.writeMessage, it writes to the UDP socket, and never checks for socket.error. If a socket.error does occur, then the query() function blows up instead of returning its deferred. So, cancelCall gets forgotten. A few seconds later, it chucks a DNSQueryTimeoutError, and the deferred gets garbage collected without anything handling it. The solution, I think, is this: - in query(), move the "self.writeMessage(m, address)" call up a few lines, to before the Deferred and callLater are created. - Trap socket.error when making this writeMessage call. If it catches one, return a defer.fail() immediately. Basically, if the UDP packet fails to be sent, then the timeout should never be created.
![](https://secure.gravatar.com/avatar/d4828a232f930a0ef907e1d314fbc993.jpg?s=120&d=mm&r=g)
On 2/27/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
Actually, I was having 2 separate issues; one was the non-handling of the socket.error, which was obvious after seeing the traceback. The other was the mysterious DNSQueryTimeoutError that I started this thread about. I filed that ticket before I realized that one was actually causing the other, but it all seems to make sense now.
participants (2)
-
Jean-Paul Calderone
-
Paul Marks