a simple example of Stackless Python

Evan Simpson evan at 4-am.com
Wed Nov 1 20:13:29 EST 2000


<brucemdawson at my-deja.com> wrote in message
news:8tqfll$m4$1 at nnrp1.deja.com...
> def main():
>     my_continuation = continuation.current()
>     k = my_continuation.update(0)
>     if k:
>         # Sub thread goes here.
>         do_thread_func()
>         del my_continuation.link
>     else:
>         # Main thread goes here, and starts sub-thread.
>         my_continuation(1)
>     # Main thread continues here.

Ah, but it doesn't continue there (at least, not right away).  There's no
forking here, it just jumps back to the "update" line and takes the other
"if" branch.  This is a very complicated way of spelling:

def main():
    do_thread_func()

What you want (I think) is microthreads, for which someone already has an
implementation.  Sorry, but that's all the info I have off the top of my
head.
--
Cheers,

Evan @ digicool & 4-am





More information about the Python-list mailing list