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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
janus-0.0.1-py3-none-any.whl
(6.8 kB
view hashes)