aiomultiprocess
Take a modern Python codebase to the next level of performance.
On their own, AsyncIO and multiprocessing are useful, but limited: AsyncIO still can't exceed the speed of GIL, and multiprocessing only works on one task at a time. But together, they can fully realize their true potential.
aiomultiprocess presents a simple interface, while running a full AsyncIO event loop on each child process, enabling levels of concurrency never before seen in a Python application. Each child process can execute multiple coroutines at once, limited only by the workload and number of cores available.
Gathering tens of thousands of network requests in seconds is as easy as:
async with Pool() as pool:
results = await pool.map(<coroutine function>, <items>)
Install
aiomultiprocess requires Python 3.6 or newer. You can install it from PyPI:
$ pip3 install aiomultiprocess
Usage
Most of aiomultiprocess mimics the standard multiprocessing module whenever possible, while accounting for places that benefit from async functionality.
Running your asynchronous jobs on a pool of worker processes is easy:
import asyncio
from aiohttp import request
from aiomultiprocess import Pool
async def get(url):
async with request("GET", url) as response:
return await response.text("utf-8")
async def main():
urls = ["https://noswap.com", ...]
async with Pool() as pool:
async for result in pool.map(get, urls):
... # process result
if __name__ == '__main__':
# Python 3.7
asyncio.run(main())
# Python 3.6
# loop = asyncio.get_event_loop()
# loop.run_until_complete(main())
Take a look at the User Guide for more details and examples.
For further context, watch the PyCon US 2018 talk about aiomultiprocess, "Thinking Outside the GIL":
Slides available at Speaker Deck.
License
aiomultiprocess is copyright Amethyst Reese, and licensed under
the MIT license. I am providing code in this repository to you under an open
source license. This is my personal repository; the license you receive to
my code is from me and not from my employer. See the LICENSE file for details.
Metadata
Release files for aiomultiprocess 0.9.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 |
|---|---|---|---|---|
| aiomultiprocess-0.9.1.tar.gz | 24.5 kB | Without provenance | Details for aiomultiprocess-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiomultiprocess-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for aiomultiprocess-0.9.1-py3-none-any.whl |
Total release size: 42.0 kB
Release files / aiomultiprocess-0.9.1.tar.gz
| Download URL | aiomultiprocess-0.9.1.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0231dbe0291e15325d7896ebeae0002d95a4f2675426ca05eb35f24c60e495b
|
|
BLAKE2b-256 checksum How to use checksums |
02d41e69e17dda5df91734b70d03dbbf9f222ddb438e1f3bf4ea8fa135ce46de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / aiomultiprocess-0.9.1-py3-none-any.whl
| Download URL | aiomultiprocess-0.9.1-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a7b3bb3c38dbfb4d9d1194ece5934b6d32cf0280e8edbe64a7d215bba1322c6
|
|
BLAKE2b-256 checksum How to use checksums |
ad14c48c2f5c96960f5649a72b96a0a31d45384b37d89a63f7ccea76bf4fceba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for aiomultiprocess 0.9.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.