[Twisted-Python] Twisted training slides

Glyph Lefkowitz glyph at twistedmatrix.com
Sat Jun 18 19:14:56 MDT 2011


On Jun 18, 2011, at 8:06 PM, Andrew Bennetts wrote:

> Jasper St. Pierre wrote:
> […]
>>  * Slide 124: As I understand, DeferredList is a bit dated, and you
>> should use gatherResults instead -- it returns a deferred, and it
>> hands you a list of all the results in the callback. The dialogue is
>> also a bit repetitive (a list of Deferreds! I hand it a list of
>> Deferreds!) and the next slide has a typo header change.
> 
> DeferredList isn't dated exactly.  You should definitely prefer
> gatherResults if it suits your situation, because it is a simpler and
> easier API.  But DeferredList is more capable, it provides more
> functionality (at the cost of being more complex to used).
> gatherResults is implemented using DeferredList.
> 
> If it really were something to avoid entirely in favour of a newer
> replacement we would have deprecated it by now :)
> 
> (IIRC there are actually one or two tickets about replacing it with
> something better, but until that happens, it's certainly reasonable to
> use.)

The ticket I can find quickly is <http://tm.tl/4977>.  Worth noting is that this ticket doesn't propose any major changes to the interface, except that it won't be a type, so you won't be able to do isinstance(x, DeferredList) any more.  But you shouldn't be doing this now, because nothing really needs to subclass Deferred.

So, when that replacement does arrive, as it stands now, changing one import line should be all you need to do to update your code.

If somebody wants to propose some changes in the new and improved version, commenting on that ticket would be a good place to start. :)



More information about the Twisted-Python mailing list