<html>
<head>
</head>
<body>
whoops... forgot to reply to stackless list.<br>
<br>
Aaron Watters wrot
<blockquote type="cite" cite="mid:3FD74894.3030006@reportlab.com">Itamar
Shtull-Trauring wrote:
  <blockquote type="cite" cite="mid:1071072549.25515.41.camel@sheriffpony">
    <pre wrap="">On Wed, 2003-12-10 at 10:50, Aaron Watters wrote:<br></pre>
    <blockquote type="cite">
      <pre wrap="">Unrolling the application at each point where you need to wait<br>simply turns the code inside out (just like unrolling<br>a set of recursions).  Threading is the only<br>acceptable alternative...<br></pre>
      </blockquote>
      <pre wrap=""><!----><br>Mmm, for some things tasklets make things a lot nicer, but I don't agree<br>threads are the only acceptable alternative. For code that is a state<br>machine (which most network protocols are), it actually works pretty<br>well. ...</pre>
      </blockquote>
 I agree, but database applications are not natural state machines. &nbsp;You
really want<br>
      <br>
 def myfunction(...):<br>
 &nbsp; &nbsp; &nbsp; do some initialization<br>
 &nbsp; &nbsp; &nbsp; while I'm not done:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prepare for the query<br>
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; result = do_query(some arguments)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; process the query...<br>
 &nbsp; &nbsp; &nbsp; &nbsp;do some other stuff...<br>
      <br>
 def do_query(some arguments):<br>
 &nbsp; &nbsp; &nbsp; if condition1:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return query(xxx)<br>
 &nbsp; &nbsp; &nbsp; elif condition2:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return query(yyy)<br>
 &nbsp; &nbsp; &nbsp; else:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return query(zzz)<br>
      <br>
 and if the query function needs to wait, it should wait. &nbsp;You don't want 
to have<br>
 to unravel the above logic into 15 tiny functions using registered callbacks, 
etcetera.<br>
      <br>
 I'd go further and argue that the reason so many network protocols<br>
 are so strange is because they have been designed around the limitations<br>
 of state-machine type implementations.<br>
      <br>
 I really think stackless type functionality makes a tremendous amount of 
sense<br>
 and I still wish it would get folded into standard Python.<br>
      <br>
 &nbsp; &nbsp; -- Aaron Watters<br>
      <br>
      </blockquote>
      <br>
      </body>
      </html>