Good day, everyone:<br><br>I'm trying to learn Python and Twisted at the same time and having fun (mostly).<br><br>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.<br>
<br>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...<br><br>The server I'm playing with, including the polling loop, is:<br><br>
from twisted.conch.telnet import StatefulTelnetProtocol<br>from twisted.internet import reactor, protocol<br><br>class TelnetEcho(StatefulTelnetProtocol):<br><br> def lineReceived(self, data):<br> print "Type of self: " + str(type(self))<br>
data = data.rstrip('\n\r')<br> self.sendLine("Unrecognized command: %r\r" % (data,))<br><br><br>def checkforspots():<br> print "running checkforspots()"<br> reactor.callLater(1.0,checkforspots)<br>
<br>def createTelnetServer():<br> factory = protocol.ServerFactory()<br><br> instance = TelnetEcho<br> factory.protocol = instance<br><br> port = reactor.listenTCP(8023,factory)<br> print "Listening on port 8023"<br>
<br> print "Type of port: " + str(type(port))<br> checkforspots()<br><br> return port<br><br>if __name__ == "__main__":<br> reactor.callWhenRunning(createTelnetServer)<br> reactor.run()<br>
<br><br>Any suggestions greatly appreciated. I've been unable to find anything using my "google-fu" on this issue - I'm stuck.<br><br>Thanks.<br><br>Mark Bailey<br>