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 queue object from the library has two faces: synchronous and asynchronous interfaces.

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):
    fut = loop.run_in_executor(None, threaded)

    for i in range(100):
        val = yield from async_q.get()
        assert val == i
        async_q.task_done()

    yield from fut

loop.run_until_complete(async_coro())

License

janus library is offered under Apache 2 license.

Changes

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.1.tar.gz (5.7 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.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for janus-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3a96430ef47c44f6925c5d17b4a948ab6e7e5203bdc094e690f653033ff9c80a
MD5 d874a866f512060e28b70ba8564b9230
BLAKE2b-256 e3c3bc2240ddc59a187a47affdcdeeac1c0d777b60b8a12142d49fe27bae95db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for janus-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e99c6e3d2737d4446668ecc02670c38a3cef4d34bf347c5bff49a66b21dd20b2
MD5 017f7cc99032a27a574154e88088183b
BLAKE2b-256 a7d8e0e4335f06ba04e812aa8cc7a480768cdc9758355e4b73cc711bb566b02a

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