Need help with crochet?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

itamarst
213 Stars 33 Forks MIT License 296 Commits 18 Opened issues

Description

Crochet: use Twisted anywhere!

Services available

!
?

Need anything else?

Contributors list

# 35,070
SQL
jupyter
Google ...
Apache ...
145 commits
# 46,638
fish-sh...
rabbitm...
s3
ec2
6 commits
# 178,741
JavaScr...
python3
fedora
asynchr...
5 commits
# 1,241
ESLint
casperj...
cython
jython
2 commits
# 184,631
Redis
Docker
JavaScr...
Haskell
2 commits
# 42,358
Rust
Firefox
coq
isometr...
1 commit
# 165,964
pre-com...
Git
Shell
JavaScr...
1 commit
# 4,749
Python
scikit-...
Redis
scrapy
1 commit
# 722,510
Python
async-p...
asynchr...
1 commit
# 81,471
python-...
iOS
osx
Kivy
1 commit

Crochet: Use Twisted anywhere!

Crochet is an MIT-licensed library that makes it easier to use Twisted from regular blocking code. Some use cases include:

  • Easily use Twisted from a blocking framework like Django or Flask.
  • Write a library that provides a blocking API, but uses Twisted for its implementation.
  • Port blocking code to Twisted more easily, by keeping a backwards compatibility layer.
  • Allow normal Twisted programs that use threads to interact with Twisted more cleanly from their threaded parts. For example, this can be useful when using Twisted as a
    WSGI container
    _.

.. _WSGI container: https://twistedmatrix.com/documents/current/web/howto/web-in-60/wsgi.html

Crochet is maintained by Itamar Turner-Trauring.

Note: Crochet development is pretty slow these days because mostly it Just Works. PyPI shows about 30,000 downloads a month, so existing users seem happy: https://pypistats.org/packages/crochet

You can install Crochet by running::

$ pip install crochet

Downloads are available on

PyPI
_.

Documentation can be found on

Read The Docs
_.

Bugs and feature requests should be filed at the project

Github page
_.

.. _Read the Docs: https://crochet.readthedocs.org/ .. _Github page: https://github.com/itamarst/crochet/ .. _PyPI: https://pypi.python.org/pypi/crochet

API and features

.. image:: https://travis-ci.org/itamarst/crochet.png?branch=master :target: http://travis-ci.org/itamarst/crochet :alt: Build Status

Crochet supports Python 2.7, 3.5, 3.6, 3.7, and 3.8 as well as PyPy and PyPy3.

Crochet provides the following basic APIs:

  • Allow blocking code to call into Twisted and block until results are available or a timeout is hit, using the
    crochet.wait_for
    decorator.
  • A lower-level API (
    crochet.run_in_reactor
    ) allows blocking code to run code "in the background" in the Twisted thread, with the ability to repeatedly check if it's done.

Crochet will do the following on your behalf in order to enable these APIs:

  • Transparently start Twisted's reactor in a thread it manages.
  • Shut down the reactor automatically when the process' main thread finishes.
  • Hook up Twisted's log system to the Python standard library
    logging
    framework. Unlike Twisted's built-in
    logging
    bridge, this includes support for blocking
    Handler
    instances.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.