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, lambda: threaded(sync_q))
loop.run_until_complete(async_coro(q.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.0.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for janus-0.0.2.tar.gz
Algorithm Hash digest
SHA256 651831e2f7f8f54a9cb19bcbdeeb64b8dc15126827054f6cf18fee3539c634a7
MD5 1977d206f1a1082cf7aa3558ce639d44
BLAKE2b-256 f3ca6fa306d93c9499e70eda3c0c174cab62d7a050dbccb2223b5d64d516f035

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for janus-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e45e4c9015c34f10d9512351b0a4f67de8ea696b0a28bea4444923a72b68496
MD5 17390b2a400b4512406edca184966278
BLAKE2b-256 98ea0d8582422a430b3940b1b12655ec384cc63b8df53d18b9d80c2cffaf879f

See more details on using hashes here.

Supported by

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