[Twisted-Python] Simple way to halt all timers?
Russell E. Owen
rowen at uw.edu
Thu Mar 13 15:09:01 MDT 2014
Is there a simple way to cancel all Twisted timers (pending
reactor.callLater calls)?
The reason I want to do this is to clean up a unit test without getting
"dirty reactor" complaints.
The system is a server that will rarely be shut down and does not have
to shut down gracefully (i.e. I don't care if the reactor is dirty). But
I want the unit tests to run cleanly, so for now I've been keeping a
reference to each timer that I start, so my test cleanup code can
manually cancel it. It's a lot of fuss, and makes timers harder to use
than they should be. I admit that in many cases I need a reference to
the timer anyway, since I may have to cancel it for reasons that matter
to the server. But I hate having to do it for *every* timer. If there
was a simple way to tell the reactor to cancel any outstanding
"callLater" calls, the code would be much cleaner.
-- Russell
More information about the Twisted-Python
mailing list