Skip to main content

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))
Decorator @concurrently makes to main thinks:
  • starts concurrent execution specified count of decorated function

  • returns special waiter object to control the running functions

By default, the code runs as asyncio coroutines, but there are other supported ways to execute, by specifying the argument engine.

Documentation

See https://concurrently.readthedocs.io/

Requirements

Now support only Python 3.5 and above.

Install

From PyPi:

$ pip install concurrently

From local:

# update setuptools
$ pip install 'setuptools >= 30.4'
# do install
$ make install
# or
$ pip install .

Development

Prepare and activate virtual environment like:

$ python3 -m venv .env
# for bash
$ source .env/bin/activate
# for fish
$ . .env/bin/activate.fish

Update pre-install dependencies:

$ pip install 'setuptools >= 30.4'

Install:

$ make install_dev
# or
$ pip install --editable .[develop]

Run tests:

$ make test
# or
$ pytest tests/

Metadata

Release files for concurrently 1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for concurrently 1
File Size Uploaded
concurrently-1.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for concurrently 1
File Interpreter ABI Platform
concurrently-1-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / concurrently-1.tar.gz

Download URL concurrently-1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bc6d6bb3cfad485d0adef6eea09c8f5e5ec6d69f01532b4a57671941395fa1a5
BLAKE2b-256 checksum
How to use checksums
6c4252ce7e85df0ceb5ca9c1433e939e1093556c13642286586320af2e13f7fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0

Release files / concurrently-1-py3-none-any.whl

Download URL concurrently-1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
658d7448a2194e5c72fb232706f818ad7a1eb6b1096cb351cf72cda11e86593a
BLAKE2b-256 checksum
How to use checksums
2ee357374c8a2ea9fa702d515948de50567714fab5c536488e33443086a585ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page