[Fedora-suds-list] Asynchrounous usage implementation (ticket 312)

Daniel Rodriguez danjrod at gmail.com
Sun May 2 23:29:09 UTC 2010


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.py

Addition of option: "async" with a default value of False. This enables the
library to behave as it does today

-- suds/client.py

Client.send (changed)

If async is True, a suds.transport.Request will be returned. This delivers
all needed information (url, headers, message) to talk to the server

Client.processreply(new)

Processes a reply offline. Called by Method.processreply. The behaviour
tries to mimic the original behavious and thus it will raise exceptions if
needed be

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.

Method.processreply(new)

Takes a suds.transport.Reply (which has code, headers and data) to invoke
Client.processreply

It has worked in my tests and I guess the changes are so few that it will
probably work.

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 regards

Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/suds/attachments/20100503/4e58ea4f/attachment.html 


More information about the suds mailing list