Synchronization primitives for Tornado coroutines
Python
Latest commit 8511700 May 29, 2016 @ajdavis Merge pull request #17 from adamchainz/readthedocs.io
Convert readthedocs link for their .org -> .io migration for hosted projects
Permalink
Failed to load latest commit information.
doc BUMP 1.0.1 Jan 27, 2016
examples
test
toro Post-release bump. Jan 27, 2016
.gitignore Starting... Sep 8, 2012
.travis.yml
LICENSE Fix setup.py, add Apache license Oct 21, 2012
MANIFEST.in
README.rst Convert readthedocs link for their .org -> .io migration for hosted p… May 29, 2016
ez_setup.py
requirements.txt Require Tornado 3 and drop Python 2.5 Mar 30, 2013
setup.py Post-release bump. Jan 27, 2016
tox.ini Drop Python 3.1, add Python 3.4. Jan 13, 2015

README.rst

toro

https://raw.github.com/ajdavis/toro/master/doc/_static/toro.png

Info:Synchronization primitives for Tornado coroutines.
Author:A. Jesse Jiryu Davis

Documentation: https://toro.readthedocs.io/

Important

Toro is completed and deprecated; its features have been merged into Tornado. Development of locks and queues for Tornado coroutines continues in Tornado itself.

https://travis-ci.org/ajdavis/toro.png

About

A set of locking and synchronizing primitives analogous to those in Python's threading module or Gevent's coros, for use with Tornado's gen.engine.

Dependencies

Tornado >= version 3.0.

Examples

Here's a basic example (for more see the examples section of the docs):

from tornado import ioloop, gen
import toro

q = toro.JoinableQueue(maxsize=3)

@gen.coroutine
def consumer():
    while True:
        item = yield q.get()
        try:
            print 'Doing work on', item
        finally:
            q.task_done()

@gen.coroutine
def producer():
    for item in range(10):
        yield q.put(item)

producer()
consumer()
loop = ioloop.IOLoop.instance()
# block until all tasks are done
q.join().add_done_callback(loop.stop)
loop.start()

Documentation

You will need Sphinx and GraphViz installed to generate the documentation. Documentation can be generated like:

$ sphinx-build doc build

Testing

Run python setup.py test in the root directory.

Toro boasts 100% code coverage, including branch-coverage!