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

Andrew Francis andrewfr_ice at yahoo.com
Mon Nov 2 10:27:37 MST 2009


Crispin:

>OK. Having a closer look, its not that looping call doesn't work, its
>that there is some unknown number of "reactor pumps" between starting
>the test, and finishing it. What I need is a way for the reactor to be
>pumping away while a particular test function of a testcase continues
>working. As an example, here is a non-working test case. Notice the
>comment "#what to do here to pump the reactor?".

...

>        while task.alive:
>            pass            #what to do here to pump the reactor?
          
This won't work because as long as the tasklet is alive (scheduled, paused,  or blocked), you will be in a tight loop. And if that function
is not running in the reactor, then the reactor will starve. If you 
are waiting to see if the tasklet finished, write a synchronizer.

Cheers,
Andrew



      




More information about the Twisted-Python mailing list