Twisted Network Programming Essentials, First Edition
by Abe Fettig
published by O'Reilly Media
ISBN 0-596-10032-9
http://www.oreilly.com/catalog/twistedadn/

The first Twisted book has made it to press. Is it the book you've been waiting for?

Check out the table of contents: The chapters are Getting Started, Building Simple Clients and Servers, Web Clients, Web Servers, Web Services and RPC, Authentication, Mail Clients, Mail Servers, NNTP Clients and Servers, SSH, and finally Services, Processes, and Logging.

That's a lot of distinct subjects in a two-hundred page book. The result is a good demonstration of how broad Twisted's domain is, but the chapters, for the most part, do not build on one another. While that allows you to skip the chapter on news servers and read the SSH chapter without much difficulty, it also means you're getting lots of separate chunks of knowledge that don't add up to anything greater than the sum of their parts.

I was hoping to see more material on general topics that apply to all Twisted programs. Interfaces, for example. Interfaces, as used in Twisted, are not a part of the Python standard library and I would not assume a reader to be familiar with how Twisted uses them. But while Interfaces do come up in a number of the examples, nowhere does the author take the time to explain why you're importing from zope.interface, how Twisted uses them or where you should start when he says "write classes to implement the foo.IBar and foo.IBarBaz interfaces." Yes, there are examples, but nothing to help you understand the theory for when you have to write your own code.

Nowhere do we learn how to write tests for asynchronous code. While the last chapter touches on the organization of services in a Twisted application, it fails to note basics like what method you'd want to implement to run tasks during a graceful shutdown. Manhole, a powerful tool for the introspection of any running application, is hidden away in the middle of the SSH chapter.

But perhaps you would like to know what is in the book, instead of what isn't:

The book is reasonably well written, the prose is neither unusually dry nor exceptionally engaging, the format is very consistent and easy to follow. In this first edition there are a number of errors, but hopefully the publisher will address those on its website.

I think the chapter on authentication is good, which I appreciate because it is one of the subjects that you will rely on for a variety of applications. The chapters on mail seem especially detailed.

The chapter on web servers is a little odd for a book whose message is "Twisted already implements the protocol," as it starts at an unrealistically low level. Yes, the book points out that the twisted.web API will someday change, but it also points out that it will use a similar organization and retain compatibility for much of the current API, so I see no need to introduce web servers as a line-oriented protocol.

So overall, if you want to embed an email server in your application, this book will give you a place to start. If you want a hard copy text to demonstrate the range of applications Twisted can reach, this book will do that. But if your main concern is that Twisted makes your head hurt and you want someone to make it seem less alien, I can't say this is the book you've been waiting for.


Kevin Turner's own experience with Twisted began years ago, and word of this has leaked to his Portland community. He now finds himself in the position of The Guy That People Point To When Someone In The User Group Asks About Twisted, and would appreciate having a good book to throw at them.

October 2005