Twisted is an open source framework for writing network based services. It utilises an asynchronous, event driven model which allows the rapid development of custom network protocols. While Twisted makes implementing network services much easier, it comes with its own set of challenges. One of these challenges involves tracking the context of multiple requests. In a traditional web server the thread ID could be used to track a particular request and modify log entries appropriately. However, this does not work in Twisted as it utilises a single thread (generally speaking).
We have chosen to tackle this issue, amongst others, by monkey patching some of the Twisted subsystems.
Through this talk we will introduce Twisted as a viable option for programming network based services. No previous Twisted knowledge is required, and the concepts introduced will be explained through real world examples of restful controllers implemented in Twisted. This primer will be followed by a discussion on our solution to the context tracking problem as well as some of the other areas in which we have found monkey patching to be beneficial.
To summarise, this talk will:
* introduce the core concepts in Twisted
* discuss how we track related actions across multiple disparate services and nodes
* tag our log entries with identifying context
* handle time jumps on underlying infrastructure
* implement clean unit tests for different environments
The talk is aimed at a general Python audience so no previous experience with Twisted is required. However, we believe that our monkey patching approach will be of interest to people currently using Twisted as well.