<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">I have a question on LoopCall.<br><br>I have a process that uses a sequence of LoopCalls, once one finishes<br>
I call the next to check for the next critical event to continue:<br><br>e.g.<br><br>   def checkForAvailableProfile(self):<br>       profile = fs_profiles_manager.get_next_available_profile()<br>       if profile is None:<br>
           return<br>       else:<br>           self.checkForAvailableProfileLoop.stop()<br><br>       self.profile = profile<br><br>       logging.debug(&quot;using profile: %s&quot;, self.profile[&#39;name&#39;])<br><br>
       self.ff = FirefoxProcess(self.profile, self.params)<br>       self.ff.run()<br><br>       self.checkForEventsFileLoop = LoopingCall(self.checkIfEventsFileExists)<br>       self.checkForEventsFileLoop.start(0.5)<br>
       self.state = self.STATE_WAIT_FOR_EVENTS<br><br>====================================================<br><br>The problem is that I&#39;m getting errors, errors when I try to call stop<br>when stop perhaps has already been called.<br>
I want advice on how to manage LoopCalls. So far I&#39;m using state variables.<br>e.g.<br>self.state = self.STATE_WAIT_FOR_EVENTS<br><br>if something goes haywire or if the process is done I have a function<br>that cleans up all the LoopCalls so it&#39;s not checking constantly:<br>
<br>   def cleanExit(self):<br>       if self.state == self.STATE_WAIT_FOR_PROFILE:<br>           self.checkForAvailableProfileLoop.stop()<br>       elif self.state == self.STATE_WAIT_FOR_EVENTS:<br>           self.checkForEventsFileLoop.stop()<br>
       elif self.state == self.STATE_WAIT_FOR_PROC_KILLED:<br>           self.checkIfFirefoxWasKilledLoop.stop()<br><br>       self.ff.cleanExit()<br><br><br>the above code is what I believe is causing my exceptions, but how<br>
else do I check for the LoopCalls?<br><br><br><br>=====================================================<br><br>2011-08-31 12:30:11-0700 [FiresharkProtocol,1278,127.0.0.1] Unhandled Error<br>   Traceback (most recent call last):<br>
     File &quot;/usr/lib/python2.6/dist-packages/twisted/application/app.py&quot;,<br>line 348, in runReactorWithLogging<br>       reactor.run()<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/base.py&quot;,<br>
line 1170, in run<br>       self.mainLoop()<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/base.py&quot;,<br>line 1182, in mainLoop<br>       self.doIteration(t)<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/selectreactor.py&quot;,<br>
line 140, in doSelect<br>       _logrun(selectable, _drdw, selectable, method, dict)<br>   --- &lt;exception caught here&gt; ---<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/python/log.py&quot;,<br>line 84, in callWithLogger<br>
       return callWithContext({&quot;system&quot;: lp}, func, *args, **kw)<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/python/log.py&quot;,<br>line 69, in callWithContext<br>       return context.call({ILogContext: newCtx}, func, *args, **kw)<br>
     File &quot;/usr/lib/python2.6/dist-packages/twisted/python/context.py&quot;,<br>line 59, in callWithContext<br>       return self.currentContext().callWithContext(ctx, func, *args, **kw)<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/python/context.py&quot;,<br>
line 37, in callWithContext<br>       return func(*args,**kw)<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/selectreactor.py&quot;,<br>line 156, in _doReadOrWrite<br>       self._disconnectSelectable(selectable, why, method==&quot;doRead&quot;)<br>
     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/posixbase.py&quot;,<br>line 194, in _disconnectSelectable<br>       selectable.connectionLost(f)<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/tcp.py&quot;,<br>
line 519, in connectionLost<br>       protocol.connectionLost(reason)<br>     File &quot;/usr/sbin/fireshark.py&quot;, line 101, in connectionLost<br>       self.cleanExit()<br>     File &quot;/usr/sbin/fireshark.py&quot;, line 43, in cleanExit<br>
       self.checkIfFirefoxWasKilledLoop.stop()<br>     File &quot;/usr/lib/python2.6/dist-packages/twisted/internet/task.py&quot;,<br>line 171, in stop<br>       assert self.running, (&quot;Tried to stop a LoopingCall that was &quot;<br>
   exceptions.AssertionError: Tried to stop a LoopingCall that was not running.<br><br><br></span>