[Twisted-Python] @inlinecallbacks and AlreadyCalledError in test cases

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Apr 4 22:21:48 EDT 2011


On 01:39 am, brad.milne at devx.runthered.com wrote:
>Hi all
>
>I have recently started switching to trial.unittest from python's own. 
>The
>trouble I'm experiencing is when a timeout occurs in my test, it 
>errbacks().
>Then the @inlineCallbacks decorator sees the error and errbacks(). But 
>then
>a second @inlineCallback in the chain subsequently sees *that* errback 
>and
>tries to errback itself. This results in AlreadyCalledError.
>
>In the test setup, various services are started. These are tracked and 
>then
>shutdown again in the teardown. Also, there is some polling that 
>happens as
>part of the tests (waiting on db activities, for example). These use
>deferLater calls, which are also tracked and torn down in the teardown.
>
>I've tried _suppressAlreadyCalled in various places to no avail.
>
>Below is a simple example that shows the problem.

I tried running the sample, it completes without error.  I guess that's 
not what you're seeing?  What version of Twisted do you have?

Jean-Paul



More information about the Twisted-Python mailing list