Twisted
More info
- Creator
- Glyph Lefkowitz
- Released
- Type
- Networking framework
- License
- MIT
- Website
- twisted.org
Python's event-driven networking framework, which had asynchronous I/O a decade before the language itself did.
Glyph Lefkowitz started writing it around 2002 — by legend, out of an attempt to build a networked game. At its core is a reactor: one loop watching every socket and calling back into your code when something happens. On top of that sit implementations of an improbable number of protocols: HTTP, SMTP, IMAP, SSH, DNS, IRC, XMPP — many of them the first complete versions in Python.
The central abstraction is the Deferred, an object representing a result that does not exist yet, onto which callbacks are attached. It is effectively the same idea as JavaScript promises, arrived at independently and several years earlier. Once Python gained asyncio in 2014 and async/await in 2015 those became the default, and Twisted now interoperates with both worlds.