Hello,<br><br>I discovered Python recently and even more recently the Twisted module.<br><br>I have a problem with the Twisted reactor and I would like to understand for which reason my program freezes.<br><br>Here the code which should loop forever :
<br><br>from twisted.internet import reactor<br>from twisted.internet import task<br><br>class reactorProb(object):<br>&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.count = 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._callback = task.LoopingCall(self.Heartbeat
)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._callback.start(1, now = False)<br>&nbsp;&nbsp;&nbsp; def Heartbeat(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Top&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.count -= 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (self.count == 0):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Exit&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self._callback.stop()
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; del self._callback<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.stop()<br><br>while (True):<br>&nbsp;&nbsp;&nbsp; rp = reactorProb()<br>&nbsp;&nbsp;&nbsp; print &quot;Enter into reactor.run()&quot;<br>&nbsp;&nbsp;&nbsp; reactor.run()<br>&nbsp;&nbsp;&nbsp; print &quot;Leave from reactor.run
()&quot;<br><br>&nbsp;&nbsp; &nbsp;<br>I got this:<br><br>Enter into reactor.run()<br>Top<br>Top<br>Top<br>Top<br>Top<br>Exit<br>Leave from reactor.run()<br>Enter into reactor.run()<br>Top<br>Top<br>Top<br>Top<br>Top<br>Exit<br><br>Thus I start first once the reactor, I stop it then I start again and it freezes instead of stopping it the reactor.
<br><br>Could somebody explain me it why?<br><br>Thank you in advance.<br><br>smu