[Twisted-Python] bug in conch tutorial

Paul Boehm typo at soniq.net
Sun Aug 24 19:15:12 MDT 2003


class CatChannel(channel.SSHChannel):
    name = 'session'
    def channelOpen(self, data):
        d = self.conn.sendRequest(self, 'exec', common.NS('cat'),
                                  wantReply = 1)
        d.addCallback(self._cbSendRequest)
        self.catData = ''

imho self.catData should be cleared before it's possible for the
deferred to fire, and append to catData.

    def _cbSendRequest(self, ignored):
        self.write('This data will be echoed back to us by "cat."\r\n')
        self.conn.sendEOF(self)
        self.loseConnection()
    def dataReceived(self, data):
        self.catData += data
    def closed(self):
        print 'We got this from "cat":', self.catData




More information about the Twisted-Python mailing list