A Python metaclass for Twisted allowing __init__ to return a Deferred
OK, I admit, this is geeky. But we’ve all run into the situation in which you’re using Python and Twisted, and you’re writing a new class and you want to call something from the __init method that...
View ArticleA kinder and more consistent defer.inlineCallbacks
Here’s a suggestion for making Twisted‘s inlineCallbacks function decorator more consistent and less confusing. Let’s suppose you’re writing something like this: @inlineCallbacks def func():...
View ArticleA mixin class allowing Python __init__ methods to work with Twisted deferreds
I posted to the Python Twisted list back in Nov 2008 with subject: A Python metaclass for Twisted allowing __init__ to return a Deferred Briefly, I was trying to find a nice way to allow the __init__...
View ArticleFacebook release Tornado and it’s not based on Twisted?
Image: Jay Smith To their great credit, Facebook have just open-sourced more of their core software. This time it’s Tornado, an asynchronous web server written in Python. Surely that can only mean one...
View ArticleFault-tolerant Python Twisted classes for getting all Twitter friends or...
It’s been forever since I blogged here. I just wrote a little Python to grab all of a user’s friends or followers (or just their user ids). It uses Twisted, of course. There were two main reasons for...
View ArticleTwisted code for retrying function calls
These days I often find myself writing code to talk to services that are periodically briefly unavailable. An error of some kind occurs and the correct (and documented) action to take is just to retry...
View ArticleAsynchronous data structures with Twisted Deferreds
Earlier this week I gave a talk titled Deferred Gratification (slides) at EuroPython in Birmingham. The title was supposed to hint at how much I love Twisted‘s Deferred class, and that it took me some...
View ArticleTwisted’s Deferred class chainDeferred method is too simplistic?
I think it’s worth spending some time thinking about whether chainDeferred in twisted.internet.defer.Deferred is too simplistic. I’ve thought for a while that it could be more helpful in preventing...
View ArticleGraceful shutdown of a Twisted service with outstanding deferreds
I’ve been spending a bit of time thinking again about queues and services. I wrote a Twisted class in 2009 to maintain a resizable dispatch queue (code in Launchpad, description on the Twisted mailing...
View ArticleHow to asynchronously exchange a dictionary using Twisted deferreds
Here’s a fun class that I can’t think of a good use for :-) But I like its simplicity and it’s another illustration of what I like to call asynchronous data structures. Suppose you have a producer...
View ArticleA resizable dispatch queue for Twisted
In December 2009 I posted to the Twisted mailing list about what I called a Resizable Dispatch Queue. I’ve just spent some time making a new version that’s much improved. You can pick up the new...
View Articletxdpce: a Twisted class for deferred parallel command execution
I just uploaded a simple Twisted Python class, txdpce, to Launchpad. It’s designed for situations where you have multiple ways of obtaining a function result and you want to try them all in parallel...
View ArticleSimpler Twisted deferred code via decorated callbacks
This morning I was thinking about Twisted deferreds and how people find them difficult to grasp, but how they’re conceptually simple once you get it. I guess most of us tell people a deferred is...
View ArticleYet another cancelable Twisted deferred class
I’m posting this (completely untested!) to illustrate how one could write a class to provide a Twisted deferred-like class, identical to the twisted.internet.defer.Deferred class, but which lets you...
View ArticlejQuery-when2 – a more flexible way to work with jQuery deferreds
I’ve often been frustrated by the limited functionality of jQuery.when. You give it some deferred objects and it fires when all the deferreds are finished. The trouble is, if any of the deferreds is...
View ArticlePromises are first-class objects for function calls
Have you ever programmed in a language without functions as first-class objects? You can’t return a function from a function, can’t pass a function as an argument, and you certainly can’t make...
View Articletxdlo – a Twisted deferred list observer
Last night I wrote txdlo, a Python package that provides a class called DeferredListObserver. As you might guess, it lets you observe callback and errback events from a list of Twisted deferreds. You...
View ArticleLearning jQuery Deferreds published
Nicholas Tollervey and I have written a book, Learning jQuery Deferreds, published by O’Reilly. If you’ve been a reader of this blog over the years, you may have noticed that I’m very fond of deferreds...
View Article
More Pages to Explore .....