[Twisted-Python] Re: gthreadless.py
nico at tekNico.net
Mon Aug 29 18:12:11 EDT 2005
> gthreadless is a twisted module that makes use of greenlets to
> implement the very nice primitive blockOn(d), that suspends the
> execution in the current stack frame while waiting for the deferred to
> fire. This way you can use a synchronous blocking-style programming
> model while still using twisted, all nicely integrated.
>From v.2.0, inside the twisted/internet/defer.py there are one class,
waitForDeferred, and one function, deferredGenerator, that implement a
similar pseudo-synchronous style, but using standard generators instead of
Defgen: Just one more reason that Twisted freakin' rocks
Furthermore, PEP 342 has been accepted for v.2.5:
Coroutines via Enhanced Generators
its enhancements should further simplify such a coding style in Twisted.
However, a couple of recent blog entries show that this way of "hiding"
Deferreds raises some eyebrows within Twisted's inner circle:
Magical Concurrency Faeries or How I Learned To Stop Worrying and Love
Knowing Santa Claus is Fake Doesn't Ruin Christmas
Personally, I think that while explicitly specifying deferreds and
callbacks and errbacks can be quite verbose, and may sometimes obscure the
program flow, the comfort of seeing clearly the boundaries of each
uninterruptible execution unit makes it worthwhile.
Nicola Larosa - nico at tekNico.net
My god carries a hammer. Your god died nailed to a tree. Any questions?
-- maxpublic on Slashdot, July 2005
More information about the Twisted-Python