[Twisted-Python] Re: Simulating time for reactor

David Bolen db3l at fitlinxx.com
Mon Jan 12 18:59:24 EST 2004


Bob Ippolito <bob at redivi.com> writes:

> On Jan 12, 2004, at 2:03 PM, Itamar Shtull-Trauring wrote:
> 
> > On Mon, 2004-01-12 at 12:35, David Bolen wrote:
> >> I was wondering if the subject of being able to override the concept
> >> of "time" for the Twisted reactor has come up before?
> >
> > Sounds like good idea. Please add an issue to twistedmatrix.com/bugs/
> > asking for a reactor.installClock(timeFunction) and a reactor.now(). JP
> > already did most of the necessary work at some point so this should be
> > easy to add.
> 
> At some point the tests should be refactored to do reactor.run(),
> too.. the whole reactor.iterate() thing is bogus.

I'm not sure I follow - I certainly couldn't just use reactor.run() in
my tests because while the objects under test will certainly be under
an overall reactor.run() loop in production use, during each test, I'm
only testing a small fraction of those objects behavior, and thus I
don't want to yield permanent control of execution to the reactor.

Having the ability to explicitly crank the reactor (via iterate) when
I want within my tests was, to me, a very positive point about Twisted
(when compared to threaded approaches for example), as it gave me
explicit control in my test environment where I needed it.

-- David





More information about the Twisted-Python mailing list