[Twisted-Python] Trial: Blocking until all deferreds have fired in test

2009-09-25 Thread Mark Visser
I have a class that looks something like this: |class FooListener(object): def __init__(self): pass @inlineCallbacks def fooBar(): try: yield doSomeSetup() doSomethingThatReturnsADeferred() returnValue('success!') except:

Re: [Twisted-Python] Trial: Blocking until all deferreds have fired in test

2009-09-25 Thread Terry Jones
Hi Mark. I'd write your FooListener class like this (untested): class FooListener(object): def fooBar(): d = doSomeSetup() d.addCallback(lambda ign: doSomethingThatReturnsADeferred()) d.addCallbacks(lambda ign: 'success!', lambda ign: 'failure!') return d And