[Twisted-Python] KeyError when an errback is triggered within a conch TCP tunnel

Luper Rouch luper.rouch at gmail.com
Wed Feb 18 23:16:34 EST 2009


Sorry I have not been able to find a better title, please see the 
attached example which may be more descriptive.

Here is what it does:
  * set up an SSH connection
  * open a TCP forwarding channel through this connection
  * do something through the tunnel that will trigger an errback (in the
    example, try to do an XMLRPC call with no one listening on the
    tunnel's end)

This scenario gives me the following traceback (tested with Twisted 
8.1.0 and 8.2.0):

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/python/log.py", 
line 84, in callWithLogger
     return callWithContext({"system": lp}, func, *args, **kw)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/python/log.py", 
line 69, in callWithContext
     return context.call({ILogContext: newCtx}, func, *args, **kw)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/python/context.py", 
line 59, in callWithContext
     return self.currentContext().callWithContext(ctx, func, *args, **kw)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/python/context.py", 
line 37, in callWithContext
     return func(*args,**kw)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/internet/selectreactor.py", 
line 156, in _doReadOrWrite
     self._disconnectSelectable(selectable, why, method=="doRead")
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/internet/posixbase.py", 
line 193, in _disconnectSelectable
     selectable.connectionLost(f)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/internet/tcp.py", 
line 520, in connectionLost
     protocol.connectionLost(reason)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/conch/ssh/forwarding.py", 
line 129, in connectionLost
     self.channel.loseConnection()
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/conch/ssh/channel.py", 
line 253, in loseConnection
     self.conn.sendClose(self)
   File 
"/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-i686.egg/twisted/conch/ssh/connection.py", 
line 491, in sendClose
     self.channelsToRemoteChannel[channel]))
exceptions.KeyError: 
<twisted.conch.ssh.forwarding.SSHListenClientForwardingChannel instance 
at 0x972048c>
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

It works well in the other cases, i.e.:
  * the errback is triggered but the tunnel is not used (comment line 57,
    uncomment line 59)
  * the errback is not triggered (start the XMLRPC server by uncommenting
    line 100), using the tunnel or not

You get the error only when the tunnel is used AND the errback is triggered.

To run the example execute it with an user name that can login using ssh 
on your host, e.g. 'python test.py someuser' and enter its password.

Cheers,
Luper
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 3121 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20090219/d11384ce/attachment.py 


More information about the Twisted-Python mailing list