<br><br><div class="gmail_quote">On Mon, Jan 16, 2012 at 1:54 PM,  <span dir="ltr">&lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 14 Jan, 09:30 am, <a href="mailto:johnaherne@rocs.co.uk">johnaherne@rocs.co.uk</a> wrote:<br>
&gt;I have been looking at JPCalderones example of using web.request with<br>
&gt;JSON<br>
&gt;which seems much like what I want.<br>
&gt;<br>
&gt;One thing I am not clear about is if I get a lot of queries coming in<br>
&gt;more<br>
&gt;or less simultaneously and I am using cooperate to allow other<br>
&gt;functions to<br>
&gt;run, will I need to guard against my data in a list being overwritten<br>
&gt;by<br>
&gt;subsequent requests.<br>
&gt;<br>
&gt;The way I see it the functions to read data and and store it in my list<br>
&gt;are<br>
&gt;in danger of impacting each other.<br>
&gt;<br>
&gt;The response is being built cooperatively bit by bit to permit other<br>
&gt;functions to run so it could happen that the next request overwrites my<br>
&gt;list where the database query is being stored.<br>
<br>
</div>Any time you have shared mutable state, you have this possibility.  You<br>
do need to take measures to avoid making one request destroy the state<br>
associated with another request.<br>
<div class="im">&gt;If this is a danger, then I need to prevent this, which seems to imply<br>
&gt;that<br>
&gt;I will need to block each request and not service another request until<br>
&gt;the<br>
&gt;previous one has completed.<br>
<br>
</div>Serializing (ie, not processing a second request until the first is<br>
completed) processing is one way to accomplish this.<br>
<br>
However, another way to accomplish it is to not have shared mutable<br>
state.  A quick skim of your code suggests you don&#39;t actually have much,<br>
if any, shared mutable state.<br>
<br>
The list holding your database results is a local variable, and each<br>
request builds its own (as far as I can tell).  There is no danger of<br>
different requests interfering with each other in this case.<br>
<br>
Jean-Paul<br>
<br>
_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
</blockquote></div>Thanks for the reply.<div><br></div><div>I think I must have been asleep when I asked this.</div><div><br></div><div>Someone else pointed this out to me earlier on but I did not have time to get to a computer before you replied.</div>
<div><br></div><div>Thanks anyway. I shall glue this to me screen for the next week or so.</div><div><br></div><div>John Aherne</div><div><br></div>