Can't debug paramiko code in Komodo IDE

When I run this paramiko code in Komdo IDE 8.5.4 on a Mac, it fails. When I run the same script from the command line, it runs fine. What do I need to do to test paramiko code in Komodo?

To me it looks like Komodo is being fooled into thinking it is debugging code on a remote host.

#!/usr/bin/python
import paramiko, os
print os.sys.platform, os.sys.version
print “Paramiko”, paramiko.version
# Komodo IDE version is 8.5.4
paramiko.util.log_to_file("/tmp/paramiko.log")
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect(‘sshhost.com’) # use a real ssh server name

When run in the debugger, this is the output

darwin 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
Paramiko 1.15.1
dbgpSocket: error: unable to connect to remote host at 127.0.0.1:60163

Unhandled exception in thread started by <function _dbgp_start_new_thread at 0x108923758>
Traceback (most recent call last):
  File "/Applications/Komodo IDE 8.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py", line 3847, in _dbgp_start_new_thread
    client.connect('', 9000, name)
  File "/Applications/Komodo IDE 8.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py", line 2313, in connect
    self.socket.connect()
  File "/Applications/Komodo IDE 8.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py", line 2161, in connect
    self._socket.connect((self.hostname,self.port))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 61] Connection refused

If I turn on ‘Listen for Debugging Connections’ under Debug then output changes to this

ERROR: dbgp.client: 
The main thread of this application is exiting while there are still threads
alive. When the main thread exits, it is system defined whether the other
threads survive.

See Caveats at http://docs.python.org/lib/module-thread.html

The Caveats link returns a 404 error.

That looks like things are working (in the second set of output)… perhaps you should set a breakpoint in there somewhere so Komodo will stop (instead of finishing the application).

Okay, I turned on “Listen for Debugging Connections” and stepped through my real program, not the little sample I uploaded, and it works. Why is this? From the first error it looks like it’s trying to connect on a localhost connection.

Can I leave “Listen” on set all the time and forget about it and lead a happy life? I only lost about an hour trying to debug my code before I discovered it runs fine from the command line.

I thought that was only to facilitate testing when the code and the IDE are on different machines. Or something like that.

–Brian

re: Debugging Connections

Komodo will always use a socket connection, even when debugging locally on the same machine. It’s because the Python/Paramiko process is completely separate to Komodo, so it needs a way to communicate back to Komodo, which it does so through this Debugging socket connection.

You’ll can leave it enabled by default and enjoy a happy life (from now anyway ;)).