[Python-Dev] Pythonic concurrency - cooperative MT (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Fri Sep 30 11:45:17 CEST 2005


(C) That scheduler is non-preemptive. A single greedy generator can starve all the others.

Instead of looking at this as a problem, you could look at it as a feature. Since generators can't be switched at arbitrary places, the programmer has to define his/her synchronization points explicitly. Let me contrast this:

So you have a scheme where you seek optimal performance (latency) but you take the risk of a huge number of difficult bugs, and you have a scheme where good performance needs more careful coding but the paradigm avoids difficult bugs /by construction/.

By the way, the cooperative MT is exactly the Twisted approach, except implemented in a different manner (event loop instead of explicit cooperative tasks).

Regards

Antoine.



More information about the Python-Dev mailing list