<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 23, 2013 at 9:46 AM, abhishek unnikrishnan <span dir="ltr">&lt;<a href="mailto:thecreator232@gmail.com" target="_blank">thecreator232@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">hi guys <div></div></div></blockquote><div><br></div><div>Hi <span name="abhishek unnikrishnan" class="">Abhishek!</span></div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>i&#39;m new to twisted and asynchronous programming . i have created a rpc server using twisted and xmlrpc packages . i wanted to know what will happen if two or more clients give an rpc call at the same time. how will the server handle this situation. </div>


<div></div></div></blockquote><div><br></div><div>The tricky part is in the &quot;at the same time&quot;. Twisted&#39;s reactor thread only does one thing at a time, and that&#39;s okay: both connections get accepted and some data gets read from them (and eventually written to them). The important part is that you do these things non-blockingly (or, synonymously, asynchronously): it&#39;s okay to only do one thing at a time as long as each thing you do takes very little time. The second connection doesn&#39;t have to wait long before the connection gets opened and data gets read, because the operations that happen before it don&#39;t take long.<br>

</div><div><br></div><div>This pattern repeats throughout asynchronous programming: it&#39;s okay to only decode one bit of JSON at a time, as long as doing that doesn&#39;t take a long time (i.e. block), preventing anything else from happening in the immediate future.<br>

<br>Does that clarify things?<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>and also wanted to know is there a way for the server to call the client in an rpc scenario .</div>

</div></blockquote><div><br></div><div>That depends on your RPC protocol. Many allow this (often called peer to peer), many are explicitly client-server and only allow one-way calls. Even protocols that do support full-duplex communication don&#39;t necessarily have clients that can take method calls very often.<br>

<br>AMP, my personal favorite, explicitly supports two-way RPC. It comes with twisted, and you can read about it here: <a href="http://amp-protocol.net/">http://amp-protocol.net/</a><br><br></div><div>Alternatively, I think JSON-RPC is full-duplex too.<br>

</div><div><br><br>cheers<br>lvh <br></div></div></div></div>