Library helps easy write concurrent executed code blocks
Project description
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
Project details
Release history Release notifications | RSS feed
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.10.0.tar.gz
(16.8 kB
view details)
File details
Details for the file concurrently-0.10.0.tar.gz
.
File metadata
- Download URL: concurrently-0.10.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a36fb84e88e0fd0726d0c3d006eb5da84cba269b4b5f723a510ffe9b27d7fae |
|
MD5 | 8485a6572d5da721aee1856374ef2226 |
|
BLAKE2b-256 | cd0b697b0a2e51e89a1376d53ce3721c9e25b526833b13ce1c1af2a97f7d2ef1 |