[Twisted-Python] Trial: Blocking until all deferreds have fired in test
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
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