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

lasizoillo lasizoillo at gmail.com
Sun May 9 10:10:14 MDT 2010


2010/5/9 Peter Cai <newptcai at gmail.com>:
> Today, a guy gave me an URL
> http://code.google.com/p/stacklessexamples/wiki/StacklessNonblockModules
>
> It's a replacement of standard python socket module. What make it
> different is that this module only blocks a tasklet, not an entire
> Python thread.
>

Gevents does monkey patching too and work with standard cpython.

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

This works with pure-python approach, not with a database driver
written in C. If you monkey-patch python threads with your tasklets,
greenlets or anything else your are lost. Mix threaded model for
blocking things and tasklet/greenlet model for non-blocking thing are
not magic :-(

> The guy who gave me that URL asked a question, "Which style is better?
> The Twited's event-driven style or the imaginary one?"
>
>
> 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?
>

IMHO (all from here)

Twisted is coherent with itself. Monkey-patched solutions pretends be
coherent with threaded style, but something fails.

Twisted pros:
 * Is not based in a thread style. Forget wich is a non-reentrant lock
and a dead-lock.
 * If you use a twisted library you don't need think about blocking
issues. If you don't use a twisted library, defer to thread.
 * It's mature.

Monkey patched pros:
 * Convert a thread style application to async one don't need a full
rewrite. Maybe it's not easy, but need less LOCs.
 * If your libraries are prue-python you don't need think, only apply
a monkey-patch.
 * Sounds cool.

Excuse my poor english,

Javi




More information about the Twisted-Python mailing list