CSP-style concurrency for Python

Overview

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.

Owner
Ziyang Hu
Attempting to build artificial general intelligence. Has a PhD in theoretical physics from the University of Cambridge.
Ziyang Hu
A simple software which can use to make a server in local network

home-nas it is simple software which can use to make a server in local network, it has a web site on it which can use by multipale system, i use nginx

R ansh joseph 1 Nov 10, 2021
Enrich IP addresses with metadata and security IoC

Stratosphere IP enrich Get an IP address and enrich it with metadata and IoC You need API keys for VirusTotal and PassiveTotal (RiskIQ) How to use fro

Stratosphere IPS 10 Sep 25, 2022
PcapXray - A Network Forensics Tool - To visualize a Packet Capture offline as a Network Diagram

PcapXray - A Network Forensics Tool - To visualize a Packet Capture offline as a Network Diagram including device identification, highlight important communication and file extraction

Srinivas P G 1.4k Dec 28, 2022
A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.

WARNING: This is from spyne's development branch. This version is not released yet! Latest stable release can be found in the 2_13 branch. If you like

1.1k Dec 23, 2022
A simple hosts picker for Microsoft Services

A simple Python scrip for you to select the fastest IP for Microsoft services.

Konnyaku 394 Dec 17, 2022
A Scapy implementation of SMS-SUBMIT and (U)SIM Application Toolkit command packets.

A Scapy implementation of SMS-SUBMIT and (U)SIM Application Toolkit command packets.

mnemonic 83 Dec 11, 2022
Medusa is a cross-platform agent compatible with both Python 3.8 and Python 2.7.

Medusa Medusa is a cross-platform agent compatible with both Python 3.8 and Python 2.7. Installation To install Medusa, you'll need Mythic installed o

Mythic Agents 123 Nov 09, 2022
Tripwire monitors ports and icmp to send the admin a message if somebody is scanning a machine that shouldn't be touched

Tripwire monitors ports and icmp to send the admin a message if somebody is scanning a machine that shouldn't be touched

3 Apr 05, 2022
Ov3 - Easy common OpenVPN3 operations

ov3 Easy common OpenVPN3 operations Install ov3 requires Python3 and OpenVPN3 to

Yunus Bora Erciyas 6 Apr 25, 2022
A socket script to obtain chinese phones-sequence for any english word

Foreign Pronunciation Generator (English-Chinese) We provide a simple socket script for acquiring Chinese pronunciation of English words (phones in ai

Ephemeroptera 5 Jul 25, 2022
Caching for HTTPX

Caching for HTTPX. Note: Early development / alpha, use at your own risk. This package adds caching functionality to HTTPX Adapted from Eric Larson's

Mehul Solanki 0 Oct 08, 2022
Build surface water network for MODFLOW's SFR Package

Surface water network Creates surface water network, which can be used to create MODFLOW's SFR. Python packages Python 3.6+ is required. Required geop

Mike Taves 20 Nov 22, 2022
EV: IDS Evasion via Packet Manipulation

EV: IDS Evasion via TCP/IP Packet Manipulation 中文文档 Introduction EV is a tool that allows you crafting TCP packets and leveraging some well-known TCP/

256 Dec 08, 2022
Visualize the electric field of a point charge network.

ElectriPy ⚡ Visualize the electric field of a point charges network. 🔌 Installation Install ElectriPy package: $ pip install electripy You are all d

Dylan Tintenfich 29 Aug 29, 2022
NetMiaou is an crossplatform hacking tool that can do reverse shells, send files, create an http server or send and receive tcp packet

NetMiaou is an crossplatform hacking tool that can do reverse shells, send files, create an http server or send and receive tcp packet

TRIKKSS 5 Oct 05, 2022
SonicWall SSL-VPN Exploit

VisualDoor SonicWall SSL-VPN Exploit, as used by Phineas Fisher to hack Cayman Trust Bank and Hacking Team.

169 Nov 15, 2022
Blockchain-Enabled IoT Sensor Framework that uses Augmented Reality and Artificial Intelligence.

Arduino + Raspberry Pi + Unity3D + Cloud + Hyperledger Our Mission: Keep it simple, leave no one behind. Blockchain-Enabled Smart Sensor Framework usi

DappAR 23 Dec 05, 2021
Public HTTPS access to Home Assistant with Dataplicity service

Custom component for public HTTPS access to Home Assistant with Dataplicity service. Should work on any Linux PC or ARM, not only Raspberry as Dataplicity service said. Don't work on Windows.

Alex X 70 Oct 03, 2022
mitm6 is a pentesting tool that exploits the default configuration of Windows to take over the default DNS server.

mitm6 is a pentesting tool that exploits the default configuration of Windows to take over the default DNS server.

Fox-IT 1.3k Jan 05, 2023
BlueHawk is an HTTP/1.1 compliant web server developed in python

This project is done as a part of Computer Networks course. It aims at the implementation of the HTTP/1.1 Protocol based on RFC 2616 and includes the basic HTTP methods of GET, POST, PUT, DELETE and

2 Nov 11, 2022