Re: [Twisted-Python] Stopping Reactor in UnitTest Callback

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. 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 From: Fabian Rothfuchs <fabian.rothfuchs@googmail.com> Date: Thursday, January 17, 2013 11:27 AM To: Twisted general discussion <twisted-python@twistedmatrix.com> Subject: Re: [Twisted-Python] Stopping Reactor in UnitTest Callback While trying to minimalize my code, I discovered that the following line somewhere down deep the code is causing the whole test to hang:
adbapi.ConnectionPool('MySQLdb', system.host, system.username, system.password, system.database)
It seems that the connection is not being closed properly, causing the whole test chain to hang. From: Itamar Turner-Trauring <itamar@futurefoundries.com> Reply-To: Twisted general discussion <twisted-python@twistedmatrix.com> Date: Tuesday, January 15, 2013 6:22 PM To: Twisted general discussion <twisted-python@twistedmatrix.com> Subject: Re: [Twisted-Python] Stopping Reactor in UnitTest Callback On Tue, Jan 15, 2013 at 10:26 AM, Fabian Rothfuchs <fabian.rothfuchs@googlemail.com> wrote:
Perhaps the problem isn't with the test framework, but with your test. Can you show us a minimal piece of code that reproduces the problem? _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.comhttp://twistedmatrix.com/cgi-bin/mailman/lis tinfo/twisted-python

On 02:34 pm, fabian.rothfuchs@googlemail.com wrote:
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

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@twistedmatrix.com" <exarkun@twistedmatrix.com> wrote:

On 02:34 pm, fabian.rothfuchs@googlemail.com wrote:
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

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@twistedmatrix.com" <exarkun@twistedmatrix.com> wrote:
participants (2)
-
exarkun@twistedmatrix.com
-
Fabian Rothfuchs