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
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 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| concurrently-2.1.tar.gz | 10.7 kB | Without provenance | Details for concurrently-2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| concurrently-2.1-py3-none-any.whl | Python 3 | none | any | Details for concurrently-2.1-py3-none-any.whl |
Total release size: 25.6 kB
Release files / concurrently-2.1.tar.gz
| Download URL | concurrently-2.1.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f477dbee46bf2deb2a88e5ed846f0306ddad34b9cf7c3d78e69be97b73904ff1
|
|
BLAKE2b-256 checksum How to use checksums |
d4cb528221dfd10c944ddc2531b6882ad13513a35670ed418a494fe328d1375b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Release files / concurrently-2.1-py3-none-any.whl
| Download URL | concurrently-2.1-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d80305f488cf400c76c575eae78c0f99c8c67d4510181f903d15d3b2722019ad
|
|
BLAKE2b-256 checksum How to use checksums |
f02e366c547b67bb44603377bbaabe92aab4e0ee2483c84b4ea475b97e996fe6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for concurrently 2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.