[PEAK] I Can't Believe It's Not Threads(tm)!
Ty Sarna
tsarna at sarna.org
Wed Feb 4 19:23:23 EST 2004
peak.events threads have some limitations that may not be obvious to
people who approach it as a lightweight threads system, as opposed to an
alternative to Twisted for asynchronous code. I'm worried that calling
them "threads" is sort of false advertising that may disapoint some
people. The fact that we keep calling Python threadmodule threads "Real
Threads" is an admission that peak.events threads are not fully "real"
in every sense, and leads to confusion.
(In a nutshell, the problem is that "yield" doesn't bubble up like an
exception does. If you have a generator calling a function calling a
generator, the inner generator can't yield a value to the outer one.
This means that code for peak.events threads have to be written in a
particular style. You can't arbitraily reuse sync code in a peak.events
environment by encapsulating peak.events behind function calls. For
example, you can't just wrap a peak.events-based async ftp connection
object behind functions that look like a fileobject, and use
cPickle.load() on it, or whatever. You have to have an events-aware
unpickling routing, or use "Real" threads in conjunction with "Fake"
threads, etc.)
As Phillip points out, there are three different models: sync, async,
and threaded. peak.events is really of the async model, not threaded.
It makes things much more *like* threaded, but it's not. Just as
margerine tastes a lot like butter, but is really in a very different
category of foods. And just like margerine is a lot more palattable
than greasy hunks of pig fat, peak.events threads tastes better than
Twisted, but... if you think you're getting butter, you'll be
disappointed. It seems to me that managing expectations is the key
here.
So the question is, should we be calling peak.events butter if it's
really margerine? One idea is to use a name that emphasizes the
similarities to threads, but also disclaims actally being threads --
like when you see "Cheez" in a product name, or "Diamonique", etc.
Should they be Thredz? Threadique? Threadites? Threadettes? Threadinos?
Something less silly? Fibers?
Comments and ideas, please!
More information about the PEAK
mailing list