Hello again,
Dear Jeff et al,Some weeks ago someone mentioned the possibility of using the library asynchronously, what would enable its usage with other libraries like Twisted and maybe avoid multithreaded scenarios.I have implemented a small set of changes that allow the library to be used asynchronously (ticket 312)Changes:-- suds/options.pyAddition of option: "async" with a default value of False. This enables the library to behave as it does today-- suds/client.pyClient.send (changed)Client.processreply(new)If async is True, a suds.transport.Request will be returned. This delivers all needed information (url, headers, message) to talk to the serverProcesses a reply offline. Called by Method.processreply. The behaviour tries to mimic the original behavious and thus it will raise exceptions if needed beMethod.processreply(new)
Part of the code in Client.send and in this method could be put in two separate methods to avoid code duplication, but I think that for an initial implementation, it is better to make as few changes as possible to the original code.
It has worked in my tests and I guess the changes are so few that it will probably work.Takes a suds.transport.Reply (which has code, headers and data) to invoke Client.processreply
A usage example:client = suds.client(wsdl, async = True)httprequest = client.service.mymethod(args) (the returned type is suds.transport.Request)httpreply = communicate_with_server(httprequest.url, httprequest.headers, httprequest.message)reply = suds.transport.Reply(httpreply.code, httpreply.headers, http.message)response = suds.client.service.mymethod.processreply(reply)Best regardsDaniel