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.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 Distribution

janus-0.1.5.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

janus-0.1.5-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file janus-0.1.5.tar.gz.

File metadata

  • Download URL: janus-0.1.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for janus-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0ad8372e065ad587ee52d43a10b90db581601b9d595cf5e735bc604ba1cb22b6
MD5 225c5d2e5c79a56efaf9b192737299db
BLAKE2b-256 9cc1113fcc9c39a20738b6727e0f3dde4495575677ac81defd49c4498380ff31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for janus-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 641d7a4c6ef5596c349b1c19abb48c1b8a55a3e35b49062cfb4053be40240b93
MD5 d24a41adf4c4db2d90d0c671dba6a751
BLAKE2b-256 aea63eccf6a82db824fb071c8ffc3cbb8b92a099f99cd20c8a49829002e6bfca

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