--- id: crochet version: "2.1.1" license: MIT license_treatment: permissive maintenance: dormant --- # crochet — Use Twisted anywhere! License: permissive · Maintenance: dormant · Downloads: 397.4K/mo ## 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 above — 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 pip install crochet uv add crochet 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_current - Install friction: low - Maintenance: dormant - Downloads: 397.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags twisted from blocking code, async reactor in threads, twisted django integration, blocking to twisted bridge, twisted wsgi adapter, reactor thread management, twisted synchronous wrapper, twisted-integration, threading-bridge, async-sync-adapter [View on SkillFed](https://skillfed.io/packages/crochet) · [View on PyPI](https://pypi.org/project/crochet/)