Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #1693 > unrolled thread

Crochet 1.4.0: use Twisted anywhere!

Started byItamar Turner-Trauring <itamar@itamarst.org>
First post2015-05-06 21:03 -0400
Last post2015-05-06 21:03 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python.announce


Contents

  Crochet 1.4.0: use Twisted anywhere! Itamar Turner-Trauring <itamar@itamarst.org> - 2015-05-06 21:03 -0400

#1693 — Crochet 1.4.0: use Twisted anywhere!

FromItamar Turner-Trauring <itamar@itamarst.org>
Date2015-05-06 21:03 -0400
SubjectCrochet 1.4.0: use Twisted anywhere!
Message-ID<mailman.220.1431071969.12865.python-announce-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python.announce


csiph-web