[Stackless] Quick question about coroutines

Christian Tismer tismer at tismer.com
Wed Jan 10 23:42:00 CET 2001


Travis Nixon wrote:
> 
> I'm looking to write a simplified sort of "task manager" in python, where
> every frame (this would be for a game) I call an update functiion and all
> the "threads" are run in a cooperative multitasking environment (I think
> that's the right term) where each thread calls sleep() when it's done for
> that update.  This tasking system would need to be as low overhead as
> possible (especially in terms of stack space).  The little bit I've managed
> to read and understand so far about coroutines leads me to believe that they
> just might do exactly what I'm looking for, but I haven't been able to put a
> lot of time in deciphering the documentation and code.
> 
> Note that where I use the term "thread" in the above, I don't really mean a
> thread, unless it's a very, very lightweight one, and I would need to have
> control over which tasks get called when, including an efficient pause (or
> the ability to sleep for more than one update as in sleep(5) )
> 
> Are coroutines what I'm looking for?  I suppose I could take what we've
> already got in C and make it the base for a python class, but I hate to
> reinvent the wheel if I don't have to. :)

You apparently want to switch your coroutines with some scheduling
system? Then you are probably looking for Microthreads. They are
included as sample code for the current Stackless distribution.

Priorities are not there yet, but Microtheads will get a C implementation
with priorities and a lot of other stuff in the next 6 months.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com
_______________________________________________
Stackless mailing list
Stackless at starship.python.net
http://starship.python.net/mailman/listinfo/stackless



More information about the Stackless mailing list