We’re going to pause for a moment to think about callbacks again. Although we now know enough about deferreds to write simple asynchronous programs in the Twisted style, the Deferred class provides more features that only come into play in more complex settings. So we’re going to think up some more complex settings and see what sort of challenges they pose when programming with callbacks. Then we’ll investigate how deferreds address those challenges.
The witches of Lancre versus vampires. Pratchett seems to be the ideal author to read while getting a tattoo. So now I only read Pratchett when getting work done. Here’s me getting some work at the Convention of the Tattoo Arts. The artist is Suzanne Shifflett. She is very good.
A quick, fascinating tour through our subconscious mind and its influence over our behavior. We seldom seem to be in as much control of ourselves as we think.
Now that we have know something about deferreds, we can rewrite our Twisted poetry client to use them. You can find client 4.0 in twisted-client-4/get-poetry.py.
Our get_poetry function no longer needs callback or errback arguments. Instead, it returns a new deferred to which the user may attach callbacks and errbacks as needed.
Focusing on what makes human beings unique, Gazzaniga reviews the latest research across many scientific disciplines. It’s all good, and written in an enjoyably informal style, but he’s at his best in the later chapters when discussing his own specialty, the human brain and mind. Will have to read some more of his stuff.
In Part 6 we came face-to-face with this fact: callbacks are a fundamental aspect of asynchronous programming with Twisted. Rather than just a way of interfacing with the reactor, callbacks will be woven into the structure of any Twisted program we write. So using Twisted, or any reactor-based asynchronous system, means organizing our code in a particular way, as a series of “callback chains” invoked by a reactor loop.
We’ve made a lot of progress with our poetry client. Our last version (2.0) is using Transports, Protocols, and Protocol Factories, the workhorses of Twisted networking. But there are more improvements to make. Client 2.0 (and also 2.1) can only be used for downloading poetry at the command line. This is because the PoetryClientFactory is not only in charge of getting poetry, but also in charge of shutting down the program when it’s finished. That’s an odd job for something called “PoetryClientFactory”, it really ought to do nothing beyond making PoetryProtocols and collecting finished poems.
A fantastic book about the observations of evolution in modern-day animals, centered around the study of Darwin’s finches on Galapagos by Rosemary and Peter grant.