[Twisted-Python] Blocking on deferreds during unit tests (e.g. deferredResult)

Christopher Armstrong radeex at gmail.com
Fri May 6 23:24:07 EDT 2005


On 5/7/05, Glyph Lefkowitz <glyph at divmod.com> wrote:
> Eric Mangold wrote:
> > I'm starting a new thread on this because It's very important to me,
> > and  we need to have some kind of resolution on this issue.
> 
> > Is there a better way to synchronously spin the reactor until a
> > deferred  fires?
> 
> Yep.  Write a unit test framework that uses Stackless and create a
> tasklet for each deferred that you want to run.

I'd suggest 1) not writing a unit test framework, and instead using
trial, and 2) instead of using stackless, use greenlet + my
gthreadless module that integrates greenlets and Deferreds
(sandbox/radix/gthreadless.py).

Alternatively, if you don't want to use greenlet, as Bob said, just
use deferred generators
(twisted.internet.defer.{deferredGenerator,waitForDeferred}).

HTH, HAND :-)

-- 
  Twisted   |  Christopher Armstrong: International Man of Twistery
   Radix    |    -- http://radix.twistedmatrix.com
            |  Release Manager, Twisted Project
  \\\V///   |    -- http://twistedmatrix.com
   |o O|    |  Founding Member, Hobart Hacking Society
w----v----w-+    -- http://hackingsociety.org/chapters/hash




More information about the Twisted-Python mailing list