[Twisted-Python] reactor.stop() doesn't stop the select reactor?

Jean-Paul Calderone exarkun at divmod.com
Tue Sep 25 15:51:24 EDT 2007

On Tue, 25 Sep 2007 12:45:07 -0700, Sam Roberts <sroberts at uniserve.com> wrote:
>I have unittests where each test:
>  def test_this
>     .. setup
>     reactor.run() # ... when test is done reactor.stop() will be called
>  def test_that
>     .. same as above
>does some setup, runs the reactor until test is complete, then stops the
>reactor, asserting all went as intended.

None of the reactors implemented in Twisted are restartable.  You can call
each of start and stop at most once.

If you are writing unit tests which require the reactor to run, then you
can either use trial and twisted.trial.unittest.TestCase or you can write
tests which cover smaller units of functionality (and hence do not require
the reactor to be running).  I'd suggest the latter as better general unit
testing practice.


More information about the Twisted-Python mailing list