[Twisted-Python] Stopping Reactor in UnitTest Callback

Fabian Rothfuchs fabian.rothfuchs at googlemail.com
Fri Jan 25 02:15:07 MST 2013


Hey Jean-Paul (and all the others in this thread),

Thank you very much for your help so far - I do really appreciate it!

I'm well aware of the fact that `deferLater` does not magically turn
blocking apps to non-blocking ones.
The idea is, whatever SUDS does, in the end it should send a SOAP request
to my
TestServer.
My problem is, that SUDS indeed sends the request, but wants to get an
immediate response, which causes a deadlock.

I just came across the very same question asked a couple of years ago:
http://stackoverflow.com/questions/2671228/python-how-can-i-use-twisted-as-
the-transport-for-suds

This should help me out of this.

Cheers
Fabian



On 1/24/13 5:00 PM, "exarkun at twistedmatrix.com"
<exarkun at twistedmatrix.com> wrote:

>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
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python






More information about the Twisted-Python mailing list