This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

asyncio special sauce

Project Description

Aioli (ayo-OH-lee) is a little sauce on top of Python’s asyncio package. With a little aioli it makes it easier to take advantage of asyncio in synchronous code.

These helpers are intended for IO bound tasks that yield. If you’re not yield’ing or if your code is CPU bound then aioli probably won’t help you much unless you start getting fancy with passing in your own loops in with their own executors.

Await

@asyncio.coroutine
def func(x):
    yield from asyncio.sleep(random())
    return x
result = aioli.await(func(1))

Map

# Func will be run asynchronously for each item in iterable and results
# will be returned in order as their available.
def func(x):
    yield from asyncio.sleep(random())
    return x

for result in aioli.map(func, iterable):
    print(result)

Parallel

# Func will be run asynchronously for each item in iterable and results
# will be returned as they are available.  Order is not guaranteed.
def inc(x):
    yield from asyncio.sleep(random())
    return x + 1

for result in aioli.parallel(func, iterable):
    print(result)

Filter

# Func will be run asynchronously for each item in iterable and results
# will be returned in order as their available.
is_even = lambda x: x % 2 == 0
for result in aioli.map(is_even, range(0, 100)):
    print(result)

Filter false

# Func will be run asynchronously for each item in iterable and results
# will be returned in order as their available.
is_even = lambda x: x % 2 == 0
for result in aioli.map(is_even, range(0, 100)):
    print(result)

Filter false

# Func will be run asynchronously for each item in iterable and results
# will be returned in order as their available.
is_even = lambda x: x % 2 == 0
for result in aioli.map(is_even, range(0, 100)):
    print(result)
Release History

Release History

This version
History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1.dev12

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
aioli-0.0.4.tar.gz (4.0 kB) Copy SHA256 Checksum SHA256 Source Mar 30, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting