Skip to main content

Library helps easy write concurrent executed code blocks

Project description

Build Status Code Coverage

Concurrently

Library helps to easily write concurrent executed code blocks.

Quick example:

import asyncio
from concurrently import concurrently


async def amain(loop):
    """
    How to fetch some web pages with concurrently.
    """
    urls = [  # define pages urls
        'http://test/page_1',
        'http://test/page_2',
        'http://test/page_3',
        'http://test/page_4',
    ]
    results = {}

    # immediately run wrapped function concurrent
    # in 2 thread (asyncio coroutines)
    @concurrently(2)
    async def fetch_urls():
        for url in urls:
            # some function for download page
            page = await fetch_page(url)
            results[url] = page

    # wait until all concurrent threads finished
    await fetch_urls()
    print(results)


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(amain(loop))

Documentation

See https://concurrently.readthedocs.io/

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

concurrently-0.9.0.tar.gz (16.6 kB view details)

Uploaded Source

File details

Details for the file concurrently-0.9.0.tar.gz.

File metadata

File hashes

Hashes for concurrently-0.9.0.tar.gz
Algorithm Hash digest
SHA256 a2f06dd4f56d52daaae9a7cfa40ff2802f3d87fbfe158ba2763afeb37e8ab831
MD5 6bf95f657d84037208ec7bc83c9f6ac9
BLAKE2b-256 df7ac8f4dc89435327d56900e95587bf64df8abc14d04cda98dd6363cf81c2dd

See more details on using hashes here.

Supported by

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