I started using twisted recently, and I'm trying to create a client that connects and sends commands to an SSH server. (I'm only creating the client and using some SSH server to test it). After sending 10 commands (e.g 'ls' command) and receiving an answer for each of the commands, my client is blocked. Can someone help me find a solution to this? Here is the most important part of my client. PS: I'm using twisted 12.0.0 (msi binaries).
class SimpleConnection(connection.SSHConnection):
def serviceStarted(self):
self.openChannel(CommandChannel(conn=self))
class CommandChannel(channel.SSHChannel):
name = 'session'
def channelOpen(self, data):
global command
command = "ls"
d = self.conn.sendRequest(self, 'exec', common.NS(command), wantReply=True)
d.addCallback(self.dataReceived)
def dataReceived(self, data):
print (data)
def closeReceived(self):
self.conn.openChannel(self)