[Twisted-Python] Stopping Reactor in UnitTest Callback

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Jan 24 11:00:06 EST 2013


On 02:34 pm, fabian.rothfuchs at googlemail.com wrote:
>Hey again!
>Having the setup doing quite well so far, I just ran into a problem 
>that I
>do not know how to debug:
>
>Testcase `setUp()` starts a server that subclasses
>`twisted.web.resource.Resource` , as it's going to be a lightweight 
>SOAP
>server, responding with hard-coded xml strings.
>Purpose is to check the request for validity.
>
>The Testcase's `test_*()` function initiates a client request by using 
>the
>suds module. I now discovered that the server process started in 
>`setUp()`
>hangs as long as the suds connection did not finish.

It looks like you're using `deferLater` as though it turns the SUDS 
client from a blocking, synchronous API into a non-blocking, 
asynchronous API.  This is not what `deferLater` does.  `deferLater` 
just schedules a function call to happen at a later time.

Your SUDS *client* is blocking the process from doing anything.  You 
need a non-blocking, asynchronous SUDS client.  You could use SUDS in a 
thread (if it is thread-safe) or you could find a different client.

Jean-Paul
>Which is a deadlock, as it cannot finish unless the server sent the
>response.
>
>When trying to connect to the server via telnet, I do not get any 
>response
>unless the suds connection is lost.
>
>Snippets:
>TestCase: http://dpaste.org/pmg6Y/
>TestServer: http://dpaste.org/NOLb8/
>Client: http://dpaste.org/2wxIV/
>
>Thanks for any help!
>Fabian



More information about the Twisted-Python mailing list