[Twisted-Python] Comparing "Stackless Python + Nonblocking Stackless Modules" with Twisted.

Glyph Lefkowitz glyph at twistedmatrix.com
Sun May 9 16:36:31 EDT 2010


On May 9, 2010, at 11:24 AM, Peter Cai wrote:

> With this module and stackless python, theoretically, we can build a
> high concurrency network application framework which has a programming
> style close to traditional multi-thread module.
> 
> The guy who gave me that URL asked a question, "Which style is better?
> The Twited's event-driven style or the imaginary one?"

Just to be clear, Imaginary (<http://divmod.org/trac/wiki/DivmodImaginary>) uses Twisted, not Stackless.

> What do you think about it?  Of course, twisted is an mature framework
> we can trust, but doesn't the imaginary one also have pros?

If by "the imaginary one" you mean "the one implemented by stacklesssocket"... you can have both.  If you want stackless-style coroutines with the Twisted mainloop, you even have multiple options!  You can use either Corotwine (<https://launchpad.net/corotwine>) or Eventlet (<http://eventlet.net/>) with its Twisted hub, which should be the default (<http://eventlet.net/doc/hubs.html#eventlet.hubs.get_default_hub>).

In my opinion, Twisted's model is "better" in the sense that it is the superset of the two models: you can implement lightweight tasks on top of Twisted's networking core, but you can't implement Twisted on top of lightweight threads because of the implied potential reentrancy of every call.

happy microthreading,

-g


More information about the Twisted-Python mailing list