[Twisted-Python] How do I get data from a Queue (or "outside") into a Telnet Server?

Mark Bailey mebly5343 at gmail.com
Mon Feb 1 21:15:04 EST 2010

Good day, everyone:

I'm trying to learn Python and Twisted at the same time and having fun

I'm writing an application that is collecting data from multiple sources,
filtering the data, and providing it to users through a Telnet server.  I
can set up a polling loop for the server but I can't figure out how to get
send the data to users connected to my server.

I thought I'd put the server in a thread and use a Queue to send data to
it.  But, I could do the work within the server application...

The server I'm playing with, including the polling loop, is:

from twisted.conch.telnet import StatefulTelnetProtocol
from twisted.internet import reactor, protocol

class TelnetEcho(StatefulTelnetProtocol):

    def lineReceived(self, data):
        print "Type of self: " + str(type(self))
        data = data.rstrip('\n\r')
        self.sendLine("Unrecognized command: %r\r" % (data,))

def checkforspots():
    print "running checkforspots()"

def createTelnetServer():
    factory = protocol.ServerFactory()

    instance = TelnetEcho
    factory.protocol = instance

    port = reactor.listenTCP(8023,factory)
    print "Listening on port 8023"

    print "Type of port: " + str(type(port))

    return port

if __name__ == "__main__":

Any suggestions greatly appreciated.  I've been unable to find anything
using my "google-fu" on this issue - I'm stuck.


Mark Bailey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100201/711a4d3b/attachment.htm 

More information about the Twisted-Python mailing list