Library / SDK
twisted/twisted avatar
twisted/twisted

Twisted: seven protocol stacks in one pip install, and a test suite that can fail under root

Event-driven networking engine written in Python.

6,010 stars1,234 forksPythonNOASSERTION

At a glance

What is it?
Twisted is an event-driven networking framework whose reactor can sit on select, poll, epoll, kqueue, IOCP or a GUI event loop, and whose distribution bundles SSH, IRC, SMTP, DNS and HTTP implementations. The maintenance picture is healthy (last push 2026-11-02, release twisted-26.10.0 on 2026-10-30), but the packaging metadata carries a live migration and the README warns that three separate conditions can turn a green suite red.
Who is it for?
Twisted fits teams that need several wire protocols in one dependency tree and want the event loop chosen per platform rather than per library. It does not fit a project that has already standardised on asyncio and needs only one protocol, since twisted.trial, the reactor and the plugin machinery all come attached.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • twisted/twisted6,010 ★ · +24
Star history
Repository2026-09-232026-11-22
twisted/twisted6k6k

24 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The reactor picks between epoll, kqueue, IOCP and three GUI loops

The central mechanism is one pluggable object, the reactor, which Twisted says works on all major system event loops: select on all platforms, poll on most POSIX platforms, epoll on Linux, kqueue on FreeBSD and macOS, and IOCP on Windows. On top of that list sit GUI event loops for GTK+2/3, Qt and wxWidgets. Third-party reactors can be plugged in to supply support for further loops, which is the extension point that makes the framework portable without being tied to one operating system selector. The practical consequence is that the choice is made at the framework level instead of per library. A program written against Twisted protocols does not carry its own readiness notification mechanism. What the project does not spell out in the README is which reactor is the default on a given platform, or how a third-party reactor is registered at runtime; that sits in the API reference on Read the Docs, not in the file a new user reads first.

Seven protocol stacks ship inside one distribution

The scope is unusually wide for a single pip install, and the module names are the fastest way to see it. `twisted.web` carries HTTP clients and servers, HTML templating and a WSGI server. `twisted.conch` provides SSHv2 and Telnet clients and servers plus terminal emulators. `twisted.words` handles IRC, XMPP and other IM protocols. `twisted.mail` implements IMAPv4, POP3 and SMTP on both sides. `twisted.names` gives you a DNS client and the tools to run your own DNS server. `twisted.positioning` talks to NMEA-compatible GPS receivers, and `twisted.trial` is a unit testing framework built to integrate with Twisted-based code. That last one is the unusual entry: the test runner is part of the networking distribution rather than a separate project. The whole set arrives with `pip install twisted`, which is the practical argument for the framework, and also the reason the dependency list is not trivial.

tox -e nocov runs what CI runs with coverage

The test entry point is tox, and the README gives four invocations that differ in what they install and whether they measure:

bash
tox -l
tox -e nocov
tox -e withcov
tox -e alldeps-withcov-posix

`tox -l` lists every environment the configuration defines, `nocov` runs the suite without coverage, `withcov` runs it with coverage, and `alldeps-withcov-posix` installs all dependencies and runs with coverage on POSIX. The POSIX suffix in the last name implies the configuration also carries per-platform environments, which matches the reactor story in the project. Changing the reactor under test is an environment variable rather than a code edit:

bash
env TWISTED_REACTOR=epoll tox -e alldeps-withcov-posix

For a user deciding whether to adopt the project, that command is the useful one, because it is the closest thing available to asking whether the suite passes under the selector your production box uses. Static checks run the same way, through pre-commit and MyPy:

bash
tox -e lint
tox -e mypy

Root, firewalls and missing extras each change the test result

The README names three conditions under which tests may fail, and none of them is a defect in the code you wrote. The first is not having the dependencies required for a particular subsystem installed, which follows from the breadth in the previous section: a missing extra can quietly skip or break the tests for one protocol family rather than the whole suite. The second is a firewall blocking some ports, and the text names Multicast explicitly, noting that Linux NAT has shown itself to do this. In a container or behind a restrictive egress policy, that failure looks like a code bug and is not. The third is running the tests as root. A CI pipeline that runs as root and a developer machine that does not may therefore disagree, and the disagreement is expected rather than surprising. None of the three has a documented flag to suppress or skip it, so the practical consequence falls on you: run the suite as the user that will run it in production, and read a port-binding failure as an environment question before reading it as a regression.

Python 3.10 is the floor and the dependencies are pinned to minors

The project metadata names `requires-python = ">=3.11"` and the classifier list runs from 3.11 through 3.14, with a comment in the file reminding maintainers to keep a matching minimum version in the CI matrix. Seven runtime dependencies are declared, and none of them is optional:

toml
requires-python = ">=3.11"
dependencies = [
    "zope.interface >= 8",
    "constantly >= 15.1",
    "incremental >= 24.7.0",
    "automat >= 24.8.1",
    "hyperlink >= 18.0.0",
    "attrs >= 22.2.0",
    "typing_extensions >= 4.13.2",
]

`zope.interface`, `attrs` and `automat` are the machinery behind Twisted's own declarative style, and `hyperlink` handles URL parsing. The test extra is where the sharp edge sits:

toml
test = [
    "cython-test-exception-raiser ~= 26.4.1",
    "PyHamcrest >= 2",
    "hypothesis >= 6.56",
    "httpx[http2] >= 0.27",
]

The comments above that block say the plan is to remove the `test` extra and skip the tests that depend on it, and that dev dependencies should be pinned to minor versions to prevent trunk failures. A contributor is therefore working against a dependency set the project already plans to dismantle.

optional-dependencies is still generated by a custom hatch hook

Look at the top of the project table and `optional-dependencies` appears in the `dynamic` list rather than as a static table, with a comment saying to remove it when the legacy optional dependency names are removed. The mechanism that fills it in is a hatch metadata hook named `custom.optional-dependencies`, and the build system requires `hatchling >= 1.10.0`, `hatch-fancy-pypi-readme >= 22.5.0` and `incremental >= 24.7.1`. `incremental` appears on both sides, once as a build requirement and once as a runtime dependency. For an application team this matters in a specific way: the extras you install by name are not declared where you would expect to find them in a normal pyproject file, so reading the metadata alone will not tell you which extra provides which protocol. The repository carries `hatch_build.py` and `lowest-constraints.txt` alongside `setup.cfg` and `tox.ini`, so the build story is spread across several files rather than contained in one.

A release titled Towncrier 26.4.0rc1 sits under a twisted tag

Three recent releases show how the project versions itself. `twisted-26.10.0` was published on 2026-10-30 under the name Twisted 26.10.0, after `twisted-26.10.0rc2` on 2026-10-27 and `twisted-26.10.0rc1` on 2026-10-22. The version scheme itself is calendar based, with a two-digit year and a month, and the pre-releases sit ahead of the final by about a week in this instance. The default branch is `trunk` rather than `main`, so scripts that assume `main` will find nothing. The last push was 2026-11-02 and the repository is not archived, so the release cadence you see here is an active one rather than a historical artefact.

GitHub reports no licence while the README says MIT

There is a small inconsistency in the licensing metadata that a legal reviewer will notice before an engineer does. The repository's licence field reads NOASSERTION, while the README states plainly that Twisted is made available under the MIT license and points at the included LICENSE file, and pyproject.toml declares `license = "MIT"`. Copyright runs 2001-2026 Twisted Matrix Laboratories, and the README carries the standard disclaimer that the software is provided as is, without warranty of any kind, and that no copyright holder or other party who modifies or redistributes it will be liable for damages. For day to day use the MIT terms are not in doubt, since two of the three sources agree and the LICENSE file is in the repository root. The gap matters if you generate an automated bill of materials from the repository field alone, because the field that most tools read is the one carrying no value. If licence provenance has to be recorded, read LICENSE rather than the field on the hosting page. Sponsorship is separate from all of this: the README says ongoing development depends on community support and lists Thinkst and SFTPPlus as sponsors.

Editorial conclusion

Twisted fits teams that need several wire protocols in one dependency tree and want the event loop chosen per platform rather than per library. It does not fit a project that has already standardised on asyncio and needs only one protocol, since twisted.trial, the reactor and the plugin machinery all come attached. Before adopting, run the tox suite on your target platforms and as the user that will actually run it, because the README names three conditions under which tests fail for reasons unrelated to the code: missing subsystem extras, ports blocked by a firewall or NAT, and running as root. Pin the exact version, and check pyproject.toml first, because optional-dependencies is still generated by a custom hatch metadata hook that the file says should go away once the legacy names are removed.

Frequently asked questions

How do I install Twisted, and what Python version does it need?

Run `pip install twisted` for the latest version. The project metadata sets `requires-python = ">=3.11"`, with classifiers covering Python 3.11 through 3.14. Additional platform-specific instructions are kept in the installation documentation on Read the Docs rather than in the README.

Which event loops can Twisted's reactor run on?

The README lists select on all platforms, poll on most POSIX platforms, epoll on Linux, kqueue on FreeBSD and macOS, and IOCP on Windows, plus GUI event loops for GTK+2/3, Qt and wxWidgets. Third-party reactors can be plugged in to support additional event loops.

How do I run the Twisted test suite?

Use tox. `tox -l` lists the environments, `tox -e nocov` runs without coverage, `tox -e withcov` runs with coverage, and `tox -e alldeps-withcov-posix` installs all dependencies and runs with coverage on POSIX. Set the `TWISTED_REACTOR` environment variable to test a specific reactor, for example `env TWISTED_REACTOR=epoll tox -e alldeps-withcov-posix`.

Why do some Twisted tests fail on my machine?

The README names three causes that are not code defects: dependencies for a particular subsystem are not installed, a firewall is blocking some ports including Multicast, which it notes Linux NAT has done, or the tests are being run as root. The project does not document a flag to suppress these conditions.

What protocols and tools does the Twisted distribution include?

Seven modules are named: `twisted.web` for HTTP clients and servers, HTML templating and a WSGI server, `twisted.conch` for SSHv2 and Telnet, `twisted.words` for IRC and XMPP, `twisted.mail` for IMAPv4, POP3 and SMTP, `twisted.positioning` for NMEA GPS receivers, `twisted.names` for DNS, and `twisted.trial` as the bundled unit testing framework.

What licence is Twisted released under?

MIT. The README states that Twisted is made available under the MIT license and points at the included LICENSE file for details, and pyproject.toml declares `license = "MIT"`. Copyright runs 2001-2026 Twisted Matrix Laboratories. Note that the repository's own licence field on the hosting page reads NOASSERTION.

Official sources

  1. Issues
  2. Project website
  3. README
  4. Releases
  5. twisted/twisted on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/twisted-twisted.svg)](https://hysenlabs.com/projects/twisted-twisted)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/twisted-twisted.svg)](https://hysenlabs.com/projects/twisted-twisted)

Was this useful?