skillfed

crochet

Use Twisted anywhere!

crochet v2.1.1 397.4K downloads/30d#6,960 on PyPI238
Permissive license MIT DORMANT released

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 crochet

uv

uv add crochet

poetry

poetry add crochet

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

twisted from blocking codeasync reactor in threadstwisted django integrationblocking to twisted bridgetwisted wsgi adapterreactor thread managementtwisted synchronous wrapper
twisted-integrationthreading-bridgeasync-sync-adapter

More Application Frameworks packages