[Twisted-Python] Q about handling CTRL-C correctly
Tommi Virtanen
tv at twistedmatrix.com
Tue May 3 07:21:27 MDT 2005
Stefan Näwe wrote:
> # global flag
> running = True
Get rid of that.
> class SimpleServer(Protocol):
> def connectionMade(self):
> m = self.factory.msg()
> while running:
> self.transport.write(m.pack())
> sys.stderr.write(".")
> time.sleep(1)
> self.transport.loseConnection()
That's blocking code, right there. Don't use time.sleep with twisted.
See task.LoopingCall and reactor.callLater.
More information about the Twisted-Python
mailing list