Blog
Twistier Poetry
Part 5: Twistier Poetry
This continues the introduction started in the first part. You can find an index to the entire series.
Abstract Expressionism
In Part 4 we made our first poetry client that uses Twisted. It works pretty well, but there is definitely room for improvement.
First of all, the client includes code for mundane details like creating network sockets and receiving data from those sockets. Twisted provides support for these sorts of things so we don’t have to implement them ourselves every time we write a new program. This is especially helpful because asynchronous I/O requires a few tricky bits involving exception handling as you can see in the client code. And there are even more tricky bits if you want your code to work on multiple platforms. If you have a free afternoon, search the Twisted sources for “win32” to see how many corner cases that platform introduces.
Book: The Pleasures and Sorrows of Work
A thoughtful and lyrical study of work, and its significance, conducted by examining the working lives of different people.
Book: Tomorrow Now: Envisioning the Next 50 Years
Book: I'll Sleep When I'm Dead: The Dirty Life and Times of Warren Zevon
Book: The Natural
Book: Woman in the Dark
Book: Database in Depth: Relational Theory for Practitioners
A crisp and readable introduction to relational database theory for practitioners, and an entertaining polemic against the current crop of relational database systems and SQL.
Twisted Poetry
Part 4: Twisted Poetry
This continues the introduction started in the first part. You can find an index to the entire series.
Our First Twisted Client
Although Twisted is probably more often used to write servers, clients are simpler than servers and we’re starting out as simply as possible. Let’s try out our first poetry client written with Twisted. The source code is in twisted-client-1/get-poetry.py. Start up some poetry servers as before:
python blocking-server/slowpoetry.py --port 10000 poetry/ecstasy.txt --num-bytes 30
python blocking-server/slowpoetry.py --port 10001 poetry/fascination.txt
python blocking-server/slowpoetry.py --port 10002 poetry/science.txt
And then run the client like this:
Our Eye-beams Begin to Twist
Part 3: Our Eye-beams Begin to Twist
This continues the introduction started in the first part. You can find an index to the entire series.
Doing Nothing, the Twisted Way
Eventually we are going to re-implement our asynchronous poetry client using Twisted. But first let’s write a few really simple Twisted programs just to get the flavor of things. As I mentioned in Part 2, I developed these examples using Twisted 8.2.0. Twisted APIs do change, but the core APIs we are going to use will likely change slowly, if at all, so I expect these examples to work for many future releases. If you don’t have Twisted installed you can obtain it from the Twisted downloads page.



