Crochet 1.4.0: use Twisted anywhere!

Itamar Turner-Trauring itamar at itamarst.org
Thu May 7 03:03:11 CEST 2015


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

from __future__ import print_function
from twisted.names import client
from crochet import setup, wait_for
setup()

@wait_for(timeout=5.0)
def gethostbyname(name):
     """Use the Twisted DNS library."""
     d = client.lookupAddress(name)
     d.addCallback(lambda result: result[0][0].payload.dottedQuad())
     return d

if __name__ == '__main__':
     # Application code using the public API - notice it works in a normal
     # blocking manner, with no event loop visible:
     import sys
     name = sys.argv[1]
     ip = gethostbyname(name)
     print(name, "->", ip)


New in 1.4.0 is Python 3.4 support as well as support for using Crochet 
with uWSGI, and additional documentation on workarounds for various 
limitations of Crochet.

https://pypi.python.org/pypi/crochet for downloads.
https://crochet.readthedocs.org/ for documentation.


--Itamar Turner-Trauring



More information about the Python-announce-list mailing list