<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. You
really want<br>
<br>
def myfunction(...):<br>
do some initialization<br>
while I'm not done:<br>
prepare for the query<br>
result = do_query(some arguments)<br>
process the query...<br>
do some other stuff...<br>
<br>
def do_query(some arguments):<br>
if condition1:<br>
return query(xxx)<br>
elif condition2:<br>
return query(yyy)<br>
else:<br>
return query(zzz)<br>
<br>
and if the query function needs to wait, it should wait. 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>
-- Aaron Watters<br>
<br>
</blockquote>
<br>
</body>
</html>