Skip to main content

Mixed sync-async queue to interoperate between asyncio tasks and classic threads

Project description

Mixed sync-async queue, supposed to be used for communicating between classic synchronous (threaded) code and asynchronous (in terms of asyncio) one.

Like Janus god the queue object from the library has two faces: synchronous and asynchronous interface.

Synchronous is fully compatible with standard queue, asynchronous one follows asyncio queue design.

Usage example

import asyncio
import janus

loop = asyncio.get_event_loop()
queue = janus.Queue(loop=loop)


def threaded(sync_q):
    for i in range(100):
        sync_q.put(i)
    sync_q.join()


@asyncio.coroutine
def async_coro(async_q):
    for i in range(100):
        val = yield from async_q.get()
        assert val == i
        async_q.task_done()


fut = loop.run_in_executor(None, threaded, queue.sync_q)
loop.run_until_complete(async_coro(queue.async_q))
loop.run_until_complete(fut)

License

janus library is offered under Apache 2 license.

Thanks

The library development is sponsored by DataRobot (http://datarobot.com/)

Changes

0.2.3 (2016-07-12)

  • Fix exception type

0.2.2 (2016-07-11)

  • Update asyncio.async() to use asyncio.ensure_future() #6

0.2.1 (2016-03-24)

  • Fix python setup.py test command #4

0.2.0 (2015-09-20)

  • Support Python 3.5

0.1.5 (2015-07-24)

  • Use loop.time() instead of time.monotonic()

0.1.1 (2015-06-12)

  • Fix some typos in README and setup.py

  • Add addtional checks for loop closing

  • Mention DataRobot

0.1.0 (2015-06-11)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

janus-0.2.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file janus-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for janus-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 82012c12c2e506ecc0ef34b6efa5e8987358ab66b16e1504acbc395f231d34ed
MD5 d43107d7d03ff1e619760df0a890645b
BLAKE2b-256 187848d30d794a851869c5800f36c4fca50611ae55fabe11c88ab012bff2a1fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page