All Projects → zh217 → Aiochan

zh217 / Aiochan

Licence: apache-2.0
CSP-style concurrency for Python

Programming Languages

python
139335 projects - #7 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Aiochan

python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (-57.76%)
Mutual labels:  concurrency, asyncio
aiorwlock
Read/Write Lock - synchronization primitive for asyncio
Stars: ✭ 90 (-22.41%)
Mutual labels:  concurrency, asyncio
think-async
🌿 Exploring cooperative concurrency primitives in Python
Stars: ✭ 178 (+53.45%)
Mutual labels:  concurrency, asyncio
Mayhem
The Python asyncio tutorial I wish existed earlier
Stars: ✭ 184 (+58.62%)
Mutual labels:  asyncio, concurrency
Asyncio
asyncio historical repository
Stars: ✭ 952 (+720.69%)
Mutual labels:  asyncio, concurrency
Pyee
A port of Node.js's EventEmitter to python
Stars: ✭ 236 (+103.45%)
Mutual labels:  asyncio, concurrency
pool
A highly flexible process pooling library for Node.js
Stars: ✭ 18 (-84.48%)
Mutual labels:  csp, concurrency
csp
A library for Communicating Sequential Processes in Node.js, built on top of async/await
Stars: ✭ 59 (-49.14%)
Mutual labels:  csp, concurrency
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+499.14%)
Mutual labels:  asyncio, concurrency
Python3 Concurrency Pics 02
爬取 www.mzitu.com 全站图片,截至目前共5162个图集,16.5万多张美女图片,使用 asyncio 和 aiohttp 实现的异步版本只需要不到2小时就能爬取完成。按日期创建图集目录,保存更合理。控制台只显示下载的进度条,详细信息保存在日志文件中。支持异常处理,不会终止爬虫程序。失败的请求,下次再执行爬虫程序时会自动下载
Stars: ✭ 275 (+137.07%)
Mutual labels:  asyncio, concurrency
Ignareo Isml Auto Voter
Ignareo the Carillon, a web spider template of ultimate concurrency built for leprechauns. Carillons as the best web spiders; Long live the golden years of leprechauns!
Stars: ✭ 154 (+32.76%)
Mutual labels:  asyncio, concurrency
Libcsp
A concurrency C library 10x faster than Golang.
Stars: ✭ 1,160 (+900%)
Mutual labels:  concurrency, csp
Sobjectizer
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
Stars: ✭ 172 (+48.28%)
Mutual labels:  concurrency, csp
SOMns
SOMns: A Newspeak for Concurrency Research
Stars: ✭ 62 (-46.55%)
Mutual labels:  csp, concurrency
Chymyst Core
Declarative concurrency in Scala - The implementation of the chemical machine
Stars: ✭ 142 (+22.41%)
Mutual labels:  concurrency, csp
csp.js
📺 CSP for vanilla JavaScript
Stars: ✭ 45 (-61.21%)
Mutual labels:  csp, concurrency
Vibe Core
Repository for the next generation of vibe.d's core package.
Stars: ✭ 56 (-51.72%)
Mutual labels:  asyncio, concurrency
So 5 5
SObjectizer: it's all about in-process message dispatching!
Stars: ✭ 87 (-25%)
Mutual labels:  concurrency, csp
Aiometer
A Python concurrency scheduling library, compatible with asyncio and trio.
Stars: ✭ 110 (-5.17%)
Mutual labels:  asyncio
Tgfilestream
A Telegram bot that can stream Telegram files to users over HTTP.
Stars: ✭ 113 (-2.59%)
Mutual labels:  asyncio

aiochan

Build Status Documentation Status codecov PyPI version PyPI version PyPI status GitHub license

logo

Aiochan is a library written to bring the wonderful idiom of CSP-style concurrency to python. The implementation is based on the battle-tested Clojure library core.async, while the API is carefully crafted to feel as pythonic as possible.

Why?

  • Doing concurrency in Python was painful
  • asyncio sometimes feels too low-level
  • I am constantly missing capabilities from golang and core.async
  • It is much easier to port core.async to Python than to port all those wonderful python packages to some other language.

What am I getting?

  • Pythonic API that includes everything you'd need for CSP-style concurrency programming
  • Works seamlessly with existing asyncio-based libraries
  • Fully tested
  • Fully documented
  • Guaranteed to work with Python 3.5.2 or above and PyPy 3.5 or above
  • Depends only on python's core libraries, zero external dependencies
  • Proven, efficient implementation based on Clojure's battle-tested core.async
  • Familiar semantics for users of golang's channels and Clojure's core.async channels
  • Flexible implementation that does not depend on the inner workings of asyncio at all
  • Permissively licensed
  • A beginner-friendly tutorial to get newcomers onboard as quickly as possible

How to install?

pip3 install aiochan

How to use?

Read the beginner-friendly tutorial that starts from the basics. Or if you are already experienced with golang or Clojure's core.async, start with the quick introduction and then dive into the API documentation.

I want to try it first

The quick introduction and the beginner-friendly tutorial can both be run in jupyter notebooks, online in binders if you want (just look for the binder link at the top of each tutorial).

Examples

In addition to the introduction and the tutorial, we have the complete set of examples from Rob Pike's Go concurrency patterns translated into aiochan. Also, here is a solution to the classical dining philosophers problem.

I still don't know how to use it

We are just starting out, but we will try to answer aiochan-related questions on stackoverflow as quickly as possible.

I found a bug

File an issue, or if you think you can solve it, a pull request is even better.

Do you use it in production? For what use cases?

aiochan is definitely not a toy and we do use it in production, mainly in the two following scenarios:

  • Complex data-flow in routing. We integrate aiochan with an asyncio-based web server. This should be easy to understand.
  • Data-preparation piplelines. We prepare and pre-process data to feed into our machine learning algorithms as fast as possible so that our algorithms spend no time waiting for data to come in, but no faster than necessary so that we don't have a memory explosion due to data coming in faster than they can be consumed. For this we make heavy use of parallel_pipe and parallel_pipe_unordered. Currently we are not aware of any other library that can completely satisfy this need of ours.

What's up with the logo?

It is our 'hello world' example:

import aiochan as ac

async def blue_python(c):
    while True:
        # do some hard work
        product = "a product made by the blue python"
        await c.put(product)

async def yellow_python(c):
    while True:
        result = await c.get()
        # use result to do amazing things
        print("A yellow python has received", result)

async def main():
    c = ac.Chan()

    for _ in range(3):
        ac.go(blue_python(c))

    for _ in range(3):
        ac.go(yellow_python(c))

in other words, it is a 3-fan-in on top of a 3-fan-out. If you run it, you will have an endless stream of A yellow python has received a product made by the blue python.

If you have no idea what this is, read the tutorial.

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