Skip to main content

miniasync is a small library build on top of asyncio to faciliate running small portions of asynchronous code in an otherwise synchronous application

Project description

miniasync

miniasync is a small library build on top of asyncio to faciliate running small portions of asynchronous code in an otherwise synchronous application.

A typical use case is an application which is build as a synchronous application, but at some point needs to make an http request to two different web services and await the results before continuing. In synchronous Python you’d have to do each request in turn - miniasync makes it easier to run both requests in parallel without having to write asyncio boilerplate code.

Example:

import aiofiles
import miniasync

async def get_file_content(filename):
    async with aiofiles.open(filename, mode='r') as f:
        return await f.read()

results = miniasync.run(
    get_file_content('file1.txt'),
    get_file_content('file2.txt'),
)

assert results == [
    '<the content of file1.txt>',
    '<the content of file2.txt>'
]

See the documentation on readthedocs for more examples and API.

License

Copyright © 2018, Alice Heaton. Released under the LGPL 3 License

Changes

V0.1.2

  • Documentation fixes

V0.1.1

  • Documentation improvements

V0.1.0

  • Initial implementation: miniasync.run and miniasync.loop

Project details


Download files

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

Source Distribution

miniasync-0.1.2.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file miniasync-0.1.2.tar.gz.

File metadata

  • Download URL: miniasync-0.1.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for miniasync-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a86d21800389b7c6f66a1cef1c06c752e2bb7592c9818719c8d21fe6c8f40962
MD5 c56552a7bd7c0db90058f84a4936263a
BLAKE2b-256 bce21c782ee568ba5390e64619d3ba8a3ed970a2eb540aa11f66b9ac3ff7e286

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page