Twisted Web with Python

Twisted is an event-driven engine, written in Python, ideal for network application development. It ensures high reliability and performance speed of the developed solutions.

Twisted event-driven frameworkJust a few years back, the developers only had forking and threaded servers  to handle concurrent connections. Yet when network sessions would reach hundreds or even thousands, those generated too many separate, resource-consuming processes to be efficient. Now, we have a better, asynchronous way for that. Twisted is a third-generation network Python framework build to tame the unruly world of event-driven programming.

Twisted Engine

Twisted is an open source asynchronous event-driven engine for network application development written entirely in Python and distributed under the MIT license. It allows you to create a SMTP, HTTP, proxy and ssh servers in a matter of minutes without the use of traditional threading models. Unlike other event-driven frameworks Twisted boasts a rich library of event-driven utility classes  for managing common protocols and programming tasks, including user authentication and remote object brokering. And as with Python, the Twisted Project has become a powerful and secure way of developing and deploying simple and elegant web applications.

Twisted Asynchronous Programming

Twisted was built assuming that with the proper library, event-driven programming will become simple and approachable. Twisted is that library. With no threads holding up valuable memory the Twisted-based event-driven servers make the best of available resources, thus developed Python applications do not suffer an otherwise usual performance hit. Twisted asynchronous single-thread programming is  the most desirable for a language such as Python.

Twisted Core

Twisted framework aims to provide the maximum functionality out of the box for network application development with:

  • Separation of protocols and transports
    Twisted separates logical protocols (usually relying on HTTP or POP3) and physical transport layers thus providing unparalleled reusability  and testability among others.
  • Thread support
    Twisted supports an abstraction over raw threads—using a thread as a deferred source. A deferred is central to the Twisted asynchronous development model as it  denotes  a value which has not been computed yet . The threading becomes clean and straightforward. A prime example of such usage is calling into databases following this model. Though the database call is performed on a foreign thread, the analysis of the result is carried out in the main thread.
  • Perspective Broker
    Twisted comes with a minimalistic remote-object framework used for dividing the servers into separate processes to offer users even more flexibility. This allows, for example, Twisted web servers to pass requests for specific URLs with co-operating servers to grant permissions  depending on the need of the specific application, instead of being forced into giving all the applications all permissions.
  • Foreign loop support
    Twisted also has a very flexible main-loop that integrates itself with foreign event loops, such as those of GTK+, Qt and Cocoa. Thus Twisted is also great as the networking support layer in GUI applications, using all of its libraries without adding unnecessary resource-consuming threads.

Twisted Applications

Even though Twisted is still a work in progress, it has become the base for many production systems:

      • Twisted supports client/server communication for the Buildbot continuous-integration system.
      • ITA Software airline-reservation system for Air Canada runs on the Twisted server.
      • Sage, an open-source alternative to Mathematica, Maple, Magma, Matlab, has a web interface that uses Twisted engine extensively.
      • The Apple Calendar Server uses Twisted, along with some internal projects of NASA.
      • FluidDB, an online cloud data-store, completely relies on Twisted to support its internal RPC and services, and for external APIs.
      • The file-hosting service Ubuntu One uses Twisted.

The list goes on and on...

You may find out more about the project by visiting its official website:


Twisted allows building scalable and reliable network software in a famously productive Python without sacrificing its development speed. Twisted is your safe business bet. If you're interested in network applications development and deployment with Twisted contact us to request a quote and learn more.

Connect with our experts Let's talk