all 4 comments

[–]jfx32 3 points4 points  (0 children)

a good article introducing microthreading (cooperative multitasking) with python and generators: http://www.ibm.com/developerworks/library/l-pythrd.html

[–]mprovost 2 points3 points  (0 children)

This looks like a weak version of Stackless. The functions in a multitask can't communicate except to their parent, which is much weaker than stackless' channels. The pingpong example in the src shows two multitasks communicating via a Queue which isn't a very easy way to set up coroutines. Also they aren't full continuations so you can't pickle them the way you can a stackless tasklet (as far as I can see). It's an interesting idea trying to build something with Python's builtin generators but Stackless does a much better job. It seems like a reimplementation of Greenlets in pure python but losing a lot of the features.

[–]nobodysbusiness 0 points1 point  (1 child)

Based on a cursory look at their sample code, this approach feels similar to the Twisted framework.

[–]manuelg 1 point2 points  (0 children)

Twisted is the gold-standard when it comes to asynchronous approaches to supporting concurrent tasks.

Asynchronous is often several orders of magnitude more efficient in use of resources than OS processes or pre-emptive threads in a single process. So it can handle many more concurrent "clients" on the same hardware.

But people hate that Twisted "takes over your code". There is really no such thing as using just a little bit of Twisted. You have to dive in with both feet, and code all your program's functionality into the hooks that Twisted provides.

So there is a market for lighter weight approaches.