I'm just learning Python and Twisted and I can't figure out for the life of me why this simple server won't work. The self.transport.write doesn't work when called from a timer. I get no error at all. Any help appreciated. Thank you very much!
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from threading import Timer
class proto(Protocol):
def saySomething(self):
self.transport.write('hello there\r\n')
def connectionMade(self):
Timer(5, self.saySomething).start()
class theFactory(Factory):
protocol = proto
reactor.listenTCP(8007, theFactory())
reactor.run()