crochet
Use Twisted anywhere!
What it is and what it does
Crochet bridges the gap between Twisted's event-driven asynchronous model and synchronous blocking code. It manages a Twisted reactor in a background thread, exposing decorators like `@wait_for` and `@run_in_reactor` that let blocking code call into Twisted and wait for results. The package handles reactor startup, shutdown, and integration with Python's standard logging framework automatically.
You use it when you need Twisted's networking or concurrency capabilities inside a blocking framework (Django, Flask, WSGI), when porting blocking code to Twisted incrementally, or when a library needs to expose a blocking API while using Twisted internally. It also supports decorating async/await Twisted functions. The main dependencies are Twisted itself and wrapt for function wrapping.
Use it for:
- Use Twisted networking in a Django or Flask web application without rewriting the entire framework.
- Write a library with a blocking API that uses Twisted for async I/O under the hood.
- Gradually port blocking code to Twisted by keeping a backwards-compatible synchronous layer.
- Run Twisted code from threaded parts of a WSGI container or other multi-threaded environment.
- Integrate Twisted's async capabilities into a synchronous test suite or blocking application.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Crochet lets you call Twisted asynchronous code from blocking Python code, managing the reactor thread automatically so you can use Twisted in Django, Flask, or other synchronous frameworks.
Yes, if you need to use Twisted from blocking code. The package is stable, well-maintained in its dormant state (no active bugs, no vulnerabilities), has low install friction, and solves a real integration problem. The 1140-day gap since the last release reflects that the library "just works" rather than abandonment—monthly downloads remain substantial. Not necessary if you're already writing pure Twisted or pure synchronous code.
Install
crochet on PyPI
pip
pip install crochetuv
uv add crochetpoetry
poetry add crochetInstalling crochet
Before you install
Low friction: pure Python wheel with only two runtime dependencies (Twisted and wrapt). Maintenance is dormant but stable—the last release was 1140 days ago, yet the package reports about 30,000 downloads per month and the repository remains active with a recent commit on 2024-09-03.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in commercial or closed-source projects.
Quickstart
pip install crochet
from crochet import setup, wait_for
from twisted.internet import reactor
setup()
@wait_for(timeout=5.0)
def blocking_call():
d = reactor.callLater(1, lambda: "result")
return d
result = blocking_call()
Requires Python 3.8 or later (3.8, 3.9, 3.10, 3.11, or PyPy3). Twisted must be installed and compatible.
Verify before relying
- Whether the package works reliably with Twisted versions released after 2023-07-01.
- Performance characteristics when handling high concurrency or long-running reactor operations.
- Compatibility with modern async/await patterns beyond the basic decorator support mentioned.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Twisted, wrapt |
| Maintenance | dormant — 1,140 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 397,417/month — #6,960 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: crochet-2.1.1-py3-none-any.whl
Keywords: twisted, threading
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
scrapydoProvides a blocking API to run Scrapy spiders…
permissive · top 15,000 on PyPI
pytest-twistedA pytest plugin that enables testing of…
permissive · top 15,000 on PyPI
txaiotxaio provides a compatibility layer that lets…
permissive · top 5,000 on PyPI
TwistedTwisted is an event-driven networking framework…
permissive · top 5,000 on PyPI
stopitProvides context managers and decorators to…
permissive · top 15,000 on PyPI
asgirefProvides ASGI base libraries including…
permissive · top 1,000 on PyPI
treqtreq is a high-level HTTP client library for…
permissive · top 15,000 on PyPI
localstack-twistedA LocalStack-optimized distribution of Twisted…
permissive · top 15,000 on PyPI
synchronicityWraps async functions, generators, and classes…
permissive · top 1,000 on PyPI
spyneSpyne is a framework for building remote…
copyleft · top 15,000 on PyPI