<div dir="ltr">thank you <span style="font-family:arial,sans-serif;font-size:13px;font-weight:bold;white-space:nowrap">Laurens Van Houtven.  </span><span style="font-family:arial,sans-serif;font-size:13px;white-space:nowrap">This was helpful and i am moving onto json-rpc for my projcet</span></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 2:03 PM, Laurens Van Houtven <span dir="ltr">&lt;<a href="mailto:_@lvh.io" target="_blank">_@lvh.io</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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">Abhishek!</span></div>
<div class="im">

<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><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 class="im"><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><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/" target="_blank">http://amp-protocol.net/</a><br><br></div><div>Alternatively, I think JSON-RPC is full-duplex too.<br>


</div><div><br><br>cheers<span class="HOEnZb"><font color="#888888"><br>lvh <br></font></span></div></div></div></div>
<br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br></div>