Hello again,<div><br></div><div>I decided that a couple of additional modifications to avoid code duplication wouldn&#39;t hurt and it looks better than I expected.</div><div><br></div><div>Since the trac system is not letting me log in right now and in case anyone would be interested in testing the asynchronous usage, this two patches have to be applied to suds/client.py and suds/options.py</div>
<div><br></div><div>As soon as the trac system allow it, the patches will be uploaded to the server</div><div><br></div><div><br><br><div class="gmail_quote">On Mon, May 3, 2010 at 01:29, Daniel Rodriguez <span dir="ltr">&lt;<a href="mailto:danjrod@gmail.com">danjrod@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Dear Jeff et al,<div><br></div><div>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.</div>

<div><br></div><div>I have implemented a small set of changes that allow the library to be used asynchronously (ticket 312)</div><div><br></div><div>Changes:</div><div><br></div><div>-- suds/options.py</div><div><br></div>

<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Addition of option: &quot;async&quot; with a default value of False. This enables the library to behave as it does today</div>
<div><br></div></blockquote><div>-- suds/client.py</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Client.send (changed)</div><div><br></div></blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>If async is True, a suds.transport.Request will be returned. This delivers all needed information (url, headers, message) to talk to the server</div>

<div><br></div></blockquote>Client.processreply(new)<br><br></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
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<br><br>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.<br>

<br></blockquote>Method.processreply(new)<br><br></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
Takes a suds.transport.Reply (which has code, headers and data) to invoke Client.processreply<br><br></blockquote></blockquote>It has worked in my tests and I guess the changes are so few that it will probably work.<div>
<br>
</div><div>A usage example:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>client = suds.client(wsdl, async = True)</div><div><br></div><div>httprequest = client.service.mymethod(args) (the returned type is suds.transport.Request)</div>

<div><br></div><div>httpreply = communicate_with_server(httprequest.url, httprequest.headers, httprequest.message)</div><div><br></div><div>reply = suds.transport.Reply(httpreply.code, httpreply.headers, http.message)</div>

<div><br></div><div>response = suds.client.service.mymethod.processreply(reply)</div></blockquote><div><br></div><div>Best regards</div><div><div><br></div><div>Daniel<br><div style="text-align:right"><br></div></div></div>

</blockquote></div><br></div>