[Twisted-Python] Real-world but self-contained example?

Jonathan Ballet jon at multani.info
Sat Jun 18 07:24:02 EDT 2011


[disclaimer: I'm a twisted newbie :) ]

On Sat, Jun 18, 2011 at 09:56:51AM +0300, Orestis Markou wrote:
> a) someone looking at the code and pointing out possible bugs or ways it could be improved or

I also reproduce the problem, so I tried to shutdown the HTTP GET first
to see what was going on, and I noticed two errors while running the code:

1) got_dns_error() is either called with a Twisted failure object (if
   the query fails) or with a Python exception if the address can't be
   resolved in _lookupName(), and the latter one doesn't have the
   getErrorMessage() method.

   I added a quick isinstance() call and now DNS resolving continues
   until all the names pool has been emptied.

2) However, at the end of the DNS lookups, I got the following error

2011-06-18 20:15:26+0900 [DNSProtocol,client] Unhandled Error
    Traceback (most recent call last):
      File "monitor7.py", line 126, in <module>
        reactor.run()
      File "/twisted/internet/base.py", line 1169, in run
        self.mainLoop()
      File "/twisted/internet/base.py", line 1181, in mainLoop
        self.doIteration(t)
      File "/twisted/internet/pollreactor.py", line 167, in doPoll
        log.callWithLogger(selectable, _drdw, selectable, fd, event)
    --- <exception caught here> ---
      File "/twisted/python/log.py", line 84, in callWithLogger
        return callWithContext({"system": lp}, func, *args, **kw)
      File "/twisted/python/log.py", line 69, in callWithContext
        return context.call({ILogContext: newCtx}, func, *args, **kw)
      File "/twisted/python/context.py", line 118, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/twisted/python/context.py", line 81, in callWithContext
        return func(*args,**kw)
      File "/twisted/internet/posixbase.py", line 587, in _doReadOrWrite
        self._disconnectSelectable(selectable, why, inRead)
      File "/twisted/internet/posixbase.py", line 257, in _disconnectSelectable
        selectable.readConnectionLost(f)
      File "/twisted/internet/tcp.py", line 221, in readConnectionLost
        self.connectionLost(reason)
      File "/twisted/internet/tcp.py", line 386, in connectionLost
        Connection.connectionLost(self, reason)
      File "/twisted/internet/tcp.py", line 232, in connectionLost
        protocol.connectionLost(reason)
      File "/twisted/names/dns.py", line 1863, in connectionLost
        self.controller.connectionLost(self)
    exceptions.AttributeError: Resolver instance has no attribute 'connectionLost'

  and I have no idea what's going on here. In this case, the
  DeferredList callback never got called.

My 2 cents,

 Jonathan



More information about the Twisted-Python mailing list