[Python-Dev] Pythonic concurrency - cooperative MT

Antoine Pitrou solipsis at pitrou.net
Fri Sep 30 16:55:25 CEST 2005


Le vendredi 30 septembre 2005 à 07:32 -0700, Simon Wittber a écrit :
> I use this approach extensively, using tasks which are defined using
> generators. The scheduler I developed for this can be viewed here:
> 
> http://metaplay.dyndns.org:82/svn/nanothreads/nanothreads.py

FWIW, I've coded my own little cooperative scheduler here:
https://developer.berlios.de/projects/tasklets/

In contrast to your approach, I don't explicitly link threads. The
"yield" keyword is used to wait on a resource (for example a
synchronised queue or a timer) and the scheduling loop manages the
switching accordingly. This approach is roughly the same as in
"gtasklets" (http://www.gnome.org/~gjc/gtasklet/gtasklets.html) except
that I don't rely on the GTK event loop.

The event loop is generic and supports asynchronous resources (resources
which become ready in another system thread: for example timers are
managed in a separate helper system thread).

It's quite alpha, but there are a few examples in the examples
directory.

Regards

Antoine.




More information about the Python-Dev mailing list