[Stackless] Re: Why does xsdb use stackless?
itamar at itamarst.org
Wed Dec 10 17:09:09 CET 2003
On Wed, 2003-12-10 at 10:50, Aaron Watters wrote:
> Unrolling the application at each point where you need to wait
> simply turns the code inside out (just like unrolling
> a set of recursions). Threading is the only
> acceptable alternative...
Mmm, for some things tasklets make things a lot nicer, but I don't agree
threads are the only acceptable alternative. For code that is a state
machine (which most network protocols are), it actually works pretty
well. Information about what's going on is stored as attributes on an
instance, rather than in local variables. For example, consider
http://cvs.twistedmatrix.com/cvs/*checkout*/twisted/protocols/pop3.py?rev=HEAD&content-type=text/plain (POP3.lineReceived will get called when the server gets a line from the client, it's a good entry point to understanding the code).
I'm not saying I wouldn't like to use tasklets myself for many things.
There's code they'd make a lot simpler. But I am not willing to use
stackless for non-technical reasons. I don't know if it will exist in
the future, and any alternative implementation of Python that comes
along won't necessarily support the tasklets stuff (e.g. Parrot, PyPy or
IronPython, one of them is going to get off the ground hopefully.) I
can't apt-get it on Debian, every time a new version of Python comes out
it depends on Christian Tismer to make new release, etc.. (I can think
of code I might want to use from packages that are 2.3 only).
By extension, depending on code that depends on stackless is also
problematic. If I ever decide I want to use xsdb I'd probably rewrite
the server component to use Twisted if it hasn't been done already.
> ...Unless I simply make the concurrency restrictions
> harsher and roll back any transaction which needs
> to wait
That is certainly not necessary in any way. Waiting for stuff is quite
possible with an event loop. Twisted includes an abstraction (called
Deferreds) which make it easier, though still not as easy to read or
organize as (I suspect) "blocking" on a channel would be.
Itamar Shtull-Trauring http://itamarst.org
Looking for a job: http://itamarst.org/resume.html
Stackless mailing list
Stackless at www.tismer.com
More information about the Stackless