[Twisted-Python] Using a custom reactor in twisted trial for test cases?

Crispin Wellington cwellington at ccg.murdoch.edu.au
Sun Nov 1 23:17:41 EST 2009


On Fri, 2009-10-30 at 14:06 +0000, exarkun at twistedmatrix.com wrote:
> It looks like your custom reactor is mainly in charge of making sure 
> stackless.schedule() gets called at least once every 0.1 seconds.  Is 
> that right?  If so, a much better approach would be to use 
> twisted.internet.task.LoopingCall rather than implementing a custom 
> reactor.
> 
> Is there something undesirable about that (much simpler, less fragile) 
> approach?

I tried using LoopingCall, but it does not work. It only calls the
scheduler once. I think this has to do with the fact that the stackless
scheduler needs to be interwoven with the twisted reactor pump. There is
more info about why it has to be done like this here:
http://code.google.com/p/stacklessexamples/wiki/StacklessTwisted

> As for your actual question, if you want a new reactor to be as usable 
> as one of the existing ones, you need to write a plugin declaring its 
> available.  Take a look at twisted/plugins/twisted_reactors.py for some 
> examples.

I shall have a look at that approach. Thanks.

Crispin




More information about the Twisted-Python mailing list