[Stackless] Quick question about coroutines

Travis Nixon tnixon at avalanchesoftware.com
Tue Jan 9 05:51:55 CET 2001

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. :)

If coroutines are in fact what I'm looking for, how difficult is it to
specify the order that the tasks are run in?  Is there some sort of priority

Or am I completely, hopelessly  misunderstanding coroutines. :)

Thanks much,
Travis Nixon

Stackless mailing list
Stackless at starship.python.net

More information about the Stackless mailing list