Skip to main content
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 notifications

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 the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
aioli-0.0.4.tar.gz (4.0 kB) Copy SHA256 hash SHA256 Source None Mar 30, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page