All Projects → h2non → Paco

h2non / Paco

Licence: mit
Small utility library for coroutine-driven asynchronous generic programming in Python 3.4+

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Paco

asynchronous
A D port of Python's asyncio library
Stars: ✭ 35 (-82.32%)
Mutual labels:  asynchronous, coroutines, asyncio
Aiotutorial
code snippets for asyncio tutorial
Stars: ✭ 257 (+29.8%)
Mutual labels:  asyncio, asynchronous, coroutines
Handle Path Oz
Android Library to handle multiple Uri's(paths) received through Intents.
Stars: ✭ 36 (-81.82%)
Mutual labels:  asynchronous, coroutines, library
Riko
A Python stream processing engine modeled after Yahoo! Pipes
Stars: ✭ 1,571 (+693.43%)
Mutual labels:  asynchronous, library
Fooproxy
稳健高效的评分制-针对性- IP代理池 + API服务,可以自己插入采集器进行代理IP的爬取,针对你的爬虫的一个或多个目标网站分别生成有效的IP代理数据库,支持MongoDB 4.0 使用 Python3.7(Scored IP proxy pool ,customise proxy data crawler can be added anytime)
Stars: ✭ 195 (-1.52%)
Mutual labels:  asyncio, coroutines
Netius
Readable, simple and fast asynchronous non-blocking network apps
Stars: ✭ 114 (-42.42%)
Mutual labels:  asyncio, library
Inapppy
Python In-app purchase validator for Apple AppStore and GooglePlay.
Stars: ✭ 110 (-44.44%)
Mutual labels:  asyncio, library
Cppcoro
A library of C++ coroutine abstractions for the coroutines TS
Stars: ✭ 2,118 (+969.7%)
Mutual labels:  asyncio, coroutines
Purerpc
Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio
Stars: ✭ 125 (-36.87%)
Mutual labels:  asyncio, asynchronous
Libwire
User space threading (aka coroutines) library for C resembling GoLang and goroutines
Stars: ✭ 149 (-24.75%)
Mutual labels:  coroutines, library
Php Ip Tools
Useful tools for IP manipulations
Stars: ✭ 152 (-23.23%)
Mutual labels:  utility, library
Edgedb Python
EdgeDB Python Driver
Stars: ✭ 113 (-42.93%)
Mutual labels:  asyncio, asynchronous
Tornado Sqlalchemy
SQLAlchemy support for Tornado
Stars: ✭ 112 (-43.43%)
Mutual labels:  asyncio, asynchronous
Synca
Synchronous asynchrony using coroutines
Stars: ✭ 118 (-40.4%)
Mutual labels:  asynchronous, coroutines
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-43.43%)
Mutual labels:  asyncio, asynchronous
Mioco
[no longer maintained] Scalable, coroutine-based, fibers/green-threads for Rust. (aka MIO COroutines).
Stars: ✭ 125 (-36.87%)
Mutual labels:  asynchronous, coroutines
Weihanli.common
common tools,methods,extension methods etc... .net 常用工具类,公共方法,常用扩展方法等,基础类库
Stars: ✭ 152 (-23.23%)
Mutual labels:  utility, library
Switchio
asyncio powered FreeSWITCH cluster control
Stars: ✭ 160 (-19.19%)
Mutual labels:  asyncio, coroutines
Txeh
Go library and CLI utilty for /etc/hosts management.
Stars: ✭ 181 (-8.59%)
Mutual labels:  utility, library
Tomorrowland
Lightweight Promises for Swift & Obj-C
Stars: ✭ 106 (-46.46%)
Mutual labels:  asynchronous, library

paco |Build Status| |PyPI| |Coverage Status| |Documentation Status| |Stability| |Quality| |Versions|

Small and idiomatic utility library for coroutine-driven asynchronous generic programming in Python +3.4.

Built on top of asyncio, paco provides missing capabilities from Python stdlib in order to write asynchronous cooperative multitasking in a nice-ish way. Also, paco aims to port some of functools and itertools_ standard functions to the asynchronous world.

paco can be your utility belt to deal with asynchronous, I/O-bound, non-blocking concurrent code in a cleaner and idiomatic way.

Features

  • Simple and idiomatic API, extending Python stdlib with async coroutines gotchas.
  • Built-in configurable control-flow concurrency support (throttle).
  • No fancy abstractions: it just works with the plain asynchronous coroutines.
  • Useful iterables, decorators, functors and convenient helpers.
  • Coroutine-based functional helpers: compose, throttle, partial, timeout, times, until, race...
  • Asynchronous coroutines port of Python built-in functions: filter, map, dropwhile, filterfalse, reduce...
  • Supports asynchronous iterables and generators (PEP0525_)
  • Concurrent iterables and higher-order functions.
  • Better asyncio.gather() and asyncio.wait() with optional concurrency control and ordered results.
  • Works with both async/await_ and yield from_ coroutines syntax.
  • Reliable coroutine timeout limit handler via context manager.
  • Designed for intensive I/O bound concurrent non-blocking tasks.
  • Good interoperability with asyncio and Python stdlib functions.
  • Composable pipelines_ of functors via | operator overloading.
  • Small and dependency free.
  • Compatible with Python +3.4.

Installation

Using pip package manager:

.. code-block:: bash

pip install --upgrade paco

Or install the latest sources from Github:

.. code-block:: bash

pip install -e git+git://github.com/h2non/paco.git#egg=paco

API

  • paco.ConcurrentExecutor_
  • paco.apply_
  • paco.compose_
  • paco.concurrent_
  • paco.constant_
  • paco.curry_
  • paco.defer_
  • paco.dropwhile_
  • paco.each_
  • paco.every_
  • paco.filter_
  • paco.filterfalse_
  • paco.flat_map_
  • paco.gather_
  • paco.identity_
  • paco.interval_
  • paco.map_
  • paco.once_
  • paco.partial_
  • paco.race_
  • paco.reduce_
  • paco.repeat_
  • paco.run_
  • paco.series_
  • paco.some_
  • paco.throttle_
  • paco.thunk_
  • paco.timeout_
  • paco.TimeoutLimit_
  • paco.times_
  • paco.until_
  • paco.wait_
  • paco.whilst_
  • paco.wraps_

.. _paco.ConcurrentExecutor: http://paco.readthedocs.io/en/latest/api.html#paco.ConcurrentExecutor .. _paco.apply: http://paco.readthedocs.io/en/latest/api.html#paco.apply .. _paco.compose: http://paco.readthedocs.io/en/latest/api.html#paco.compose .. _paco.concurrent: http://paco.readthedocs.io/en/latest/api.html#paco.concurrent .. _paco.constant: http://paco.readthedocs.io/en/latest/api.html#paco.constant .. _paco.curry: http://paco.readthedocs.io/en/latest/api.html#paco.curry .. _paco.defer: http://paco.readthedocs.io/en/latest/api.html#paco.defer .. _paco.dropwhile: http://paco.readthedocs.io/en/latest/api.html#paco.dropwhile .. _paco.each: http://paco.readthedocs.io/en/latest/api.html#paco.each .. _paco.every: http://paco.readthedocs.io/en/latest/api.html#paco.every .. _paco.filter: http://paco.readthedocs.io/en/latest/api.html#paco.filter .. _paco.filterfalse: http://paco.readthedocs.io/en/latest/api.html#paco.filterfalse .. _paco.flat_map: http://paco.readthedocs.io/en/latest/api.html#paco.flat_map .. _paco.gather: http://paco.readthedocs.io/en/latest/api.html#paco.gather .. _paco.identity: http://paco.readthedocs.io/en/latest/api.html#paco.identity .. _paco.interval: http://paco.readthedocs.io/en/latest/api.html#paco.interval .. _paco.map: http://paco.readthedocs.io/en/latest/api.html#paco.map .. _paco.once: http://paco.readthedocs.io/en/latest/api.html#paco.once .. _paco.partial: http://paco.readthedocs.io/en/latest/api.html#paco.partial .. _paco.race: http://paco.readthedocs.io/en/latest/api.html#paco.race .. _paco.reduce: http://paco.readthedocs.io/en/latest/api.html#paco.reduce .. _paco.repeat: http://paco.readthedocs.io/en/latest/api.html#paco.repeat .. _paco.run: http://paco.readthedocs.io/en/latest/api.html#paco.run .. _paco.series: http://paco.readthedocs.io/en/latest/api.html#paco.series .. _paco.some: http://paco.readthedocs.io/en/latest/api.html#paco.some .. _paco.throttle: http://paco.readthedocs.io/en/latest/api.html#paco.throttle .. _paco.thunk: http://paco.readthedocs.io/en/latest/api.html#paco.thunk .. _paco.timeout: http://paco.readthedocs.io/en/latest/api.html#paco.timeout .. _paco.TimeoutLimit: http://paco.readthedocs.io/en/latest/api.html#paco.TimeoutLimit .. _paco.times: http://paco.readthedocs.io/en/latest/api.html#paco.times .. _paco.until: http://paco.readthedocs.io/en/latest/api.html#paco.until .. _paco.wait: http://paco.readthedocs.io/en/latest/api.html#paco.wait .. _paco.whilst: http://paco.readthedocs.io/en/latest/api.html#paco.whilst .. _paco.wraps: http://paco.readthedocs.io/en/latest/api.html#paco.wraps

Examples ^^^^^^^^

Asynchronously and concurrently execute multiple HTTP requests.

.. code-block:: python

import paco
import aiohttp

async def fetch(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as res:
            return res

async def fetch_urls():
    urls = [
        'https://www.google.com',
        'https://www.yahoo.com',
        'https://www.bing.com',
        'https://www.baidu.com',
        'https://duckduckgo.com',
    ]

    # Map concurrent executor with concurrent limit of 3
    responses = await paco.map(fetch, urls, limit=3)

    for res in responses:
        print('Status:', res.status)

# Run in event loop
paco.run(fetch_urls())

Concurrent pipeline-style composition of transform functors over an iterable object.

.. code-block:: python

import paco

async def filterer(x):
    return x < 8

async def mapper(x):
    return x * 2

async def drop(x):
    return x < 10

async def reducer(acc, x):
    return acc + x

async def task(numbers):
    return await (numbers
                   | paco.filter(filterer)
                   | paco.map(mapper)
                   | paco.dropwhile(drop)
                   | paco.reduce(reducer, initializer=0))

# Run in event loop
number = paco.run(task((1, 2, 3, 4, 5, 6, 7, 8, 9, 10)))
print('Number:', number) # => 36

License

MIT - Tomas Aparicio

.. _asynchronous: http://python.org .. _asyncio: https://docs.python.org/3.5/library/asyncio.html .. _Python: http://python.org .. _annotated API reference: https://h2non.github.io/paco .. _async/await: https://www.python.org/dev/peps/pep-0492/ .. _yield from: https://www.python.org/dev/peps/pep-0380/ .. _Composable pipelines: #examples .. _itertools: https://docs.python.org/3/library/itertools.html .. _functools: https://docs.python.org/3/library/functools.html .. _PEP0525: https://www.python.org/dev/peps/pep-0525/

.. |Build Status| image:: https://travis-ci.org/h2non/paco.svg?branch=master :target: https://travis-ci.org/h2non/paco .. |PyPI| image:: https://img.shields.io/pypi/v/paco.svg?maxAge=2592000?style=flat-square :target: https://pypi.python.org/pypi/paco .. |Coverage Status| image:: https://coveralls.io/repos/github/h2non/paco/badge.svg?branch=master :target: https://coveralls.io/github/h2non/paco?branch=master .. |Documentation Status| image:: https://img.shields.io/badge/docs-latest-green.svg?style=flat :target: http://paco.readthedocs.io/en/latest/?badge=latest .. |Quality| image:: https://codeclimate.com/github/h2non/paco/badges/gpa.svg :target: https://codeclimate.com/github/h2non/paco .. |Stability| image:: https://img.shields.io/pypi/status/paco.svg :target: https://pypi.python.org/pypi/paco .. |Versions| image:: https://img.shields.io/pypi/pyversions/paco.svg :target: https://pypi.python.org/pypi/paco

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