All Projects → aio-libs → Janus

aio-libs / Janus

Licence: apache-2.0
Thread-safe asyncio-aware queue for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Janus

Loafer
Asynchronous message dispatcher - Currently using asyncio and amazon SQS
Stars: ✭ 104 (-78.11%)
Mutual labels:  asyncio, queue
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+46.32%)
Mutual labels:  asyncio, queue
rearq
A distributed task queue built with asyncio and redis, with built-in web interface
Stars: ✭ 81 (-82.95%)
Mutual labels:  queue, asyncio
Fennel
A task queue library for Python and Redis
Stars: ✭ 24 (-94.95%)
Mutual labels:  asyncio, queue
aioScrapy
基于asyncio与aiohttp的异步协程爬虫框架 欢迎Star
Stars: ✭ 34 (-92.84%)
Mutual labels:  queue, asyncio
spinach
Modern Redis task queue for Python 3
Stars: ✭ 46 (-90.32%)
Mutual labels:  queue, asyncio
think-async
🌿 Exploring cooperative concurrency primitives in Python
Stars: ✭ 178 (-62.53%)
Mutual labels:  queue, asyncio
Nats.py
Python3 client for NATS.io
Stars: ✭ 384 (-19.16%)
Mutual labels:  asyncio
Datastructure
常用数据结构及其算法的Java实现,包括但不仅限于链表、栈,队列,树,堆,图等经典数据结构及其他经典基础算法(如排序等)...
Stars: ✭ 419 (-11.79%)
Mutual labels:  queue
Nsq
A realtime distributed messaging platform
Stars: ✭ 20,663 (+4250.11%)
Mutual labels:  queue
Django Private Chat
Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team
Stars: ✭ 376 (-20.84%)
Mutual labels:  asyncio
Queue Interop
Promoting the interoperability of message queue objects.
Stars: ✭ 399 (-16%)
Mutual labels:  queue
Aiomonitor
aiomonitor is module that adds monitor and python REPL capabilities for asyncio application
Stars: ✭ 430 (-9.47%)
Mutual labels:  asyncio
Mangos
mangos is a pure Golang implementation of nanomsg's "Scalablilty Protocols"
Stars: ✭ 384 (-19.16%)
Mutual labels:  queue
Blacksheep
Fast ASGI web framework and HTTP client for Python asyncio
Stars: ✭ 450 (-5.26%)
Mutual labels:  asyncio
Uvicorn
The lightning-fast ASGI server. 🦄
Stars: ✭ 4,676 (+884.42%)
Mutual labels:  asyncio
Coding Interview Gym
leetcode.com , algoexpert.io solutions in python and swift
Stars: ✭ 451 (-5.05%)
Mutual labels:  queue
Jocko
Kafka implemented in Golang with built-in coordination (No ZK dep, single binary install, Cloud Native)
Stars: ✭ 4,445 (+835.79%)
Mutual labels:  queue
Python Betterproto
Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
Stars: ✭ 412 (-13.26%)
Mutual labels:  asyncio
Ring
Python cache interface with clean API and built-in memcache & redis + asyncio support.
Stars: ✭ 404 (-14.95%)
Mutual labels:  asyncio

======= janus

.. image:: https://travis-ci.com/aio-libs/janus.svg?branch=master :target: https://travis-ci.com/aio-libs/janus .. image:: https://codecov.io/gh/aio-libs/janus/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/janus .. image:: https://img.shields.io/pypi/v/janus.svg :target: https://pypi.python.org/pypi/janus .. image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/aio-libs/Lobby :alt: Chat on Gitter

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 <https://en.wikipedia.org/wiki/Janus>_ the queue object from the library has two faces: synchronous and asynchronous interface.

Synchronous is fully compatible with standard queue <https://docs.python.org/3/library/queue.html>, asynchronous one follows asyncio queue design <https://docs.python.org/3/library/asyncio-queue.html>.

Usage example (Python 3.7+)

.. code:: python

import asyncio
import janus


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


async def async_coro(async_q):
    for i in range(100):
        val = await async_q.get()
        assert val == i
        async_q.task_done()


async def main():
    queue = janus.Queue()
    loop = asyncio.get_running_loop()
    fut = loop.run_in_executor(None, threaded, queue.sync_q)
    await async_coro(queue.async_q)
    await fut
    queue.close()
    await queue.wait_closed()


asyncio.run(main())

Usage example (Python 3.5 and 3.6)

.. code:: python

import asyncio
import janus

loop = asyncio.get_event_loop()


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


async def async_coro(async_q):
    for i in range(100):
        val = await async_q.get()
        assert val == i
        async_q.task_done()


async def main():
    queue = janus.Queue()
    fut = loop.run_in_executor(None, threaded, queue.sync_q)
    await async_coro(queue.async_q)
    await fut
    queue.close()
    await queue.wait_closed()

try:
    loop.run_until_complete(main())
finally:
    loop.close()

Communication channels

aio-libs google group: https://groups.google.com/forum/#!forum/aio-libs

Feel free to post your questions and ideas here.

gitter chat https://gitter.im/aio-libs/Lobby

License

janus library is offered under Apache 2 license.

Thanks

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

.. _asyncio: https://docs.python.org/3/library/asyncio.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].