Skip to main content

An async, (hopefully soon fully) concurrent.futures.Executor compliant, android compatible process pool implementation

Project description

aio_process_pool

PyPI - Version PyPI - Python Version


Tihs pacakage provides an async, (hopefully soon fully) concurrent.futures.Executor compliant, android compatible process pool.

Table of Contents

Installation

pip install aio_process_pool

Usage

from aio_process_pool import ProcessPool, Executor

def foo(x):
    return x

# Note:
# - the process pool must be initialize AFTER all functions that are supposed
#   to be called are defined
# - it's not save to initialize a process pool from a multithreaded process
#   because it's based on `os.fork` / `multiprocessing.Process`

pool = ProcessPool()
executor = Executor()

async def pool_example():
    return await pool.run(foo, 72)

async def executor_example():
    from functools import partial

    loop = asyncio.get_event_loop()
    return await loop.run_in_executor(executor, partial(foo, 74))

Demo

import asyncio
from aio_process_pool import Executor

def fib(n):
    if n <= 2: return 1
    return fib(n-1) + fib(n-2)

def fib_wrapper(n):
    print(f"fib({n}) = .....")
    result = fib(n)
    print(f"fib({n}) = {result}")

async def watch_htop_and_output_while_execution():
    pool = Executor()
    await pool.map_async(fib_wrapper, range(45))

asyncio.run(watch_htop_and_output_while_execution())

License

aio_process_pool is distributed under the terms of the MIT license.

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

aio_process_pool-0.0.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio_process_pool-0.0.4-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file aio_process_pool-0.0.4.tar.gz.

File metadata

  • Download URL: aio_process_pool-0.0.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for aio_process_pool-0.0.4.tar.gz
Algorithm Hash digest
SHA256 685542d9c6ffd4291670bcbefe54a03aba29e7a52450defa8333340dc215c8b3
MD5 821db8c2ea89c80e8be1a6ff4e8d9591
BLAKE2b-256 3f4911757dcd6ed927dd45ace098fdb9ff7254e5eb8aa9ce3fa3edf2f8f2a78f

See more details on using hashes here.

File details

Details for the file aio_process_pool-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for aio_process_pool-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 321ed9be3c51612c918cd8c4a9a90295e0ad9c1fe8feb3cb8fcb17dae576b7e5
MD5 b320fe1813c653bdd986de09e94d31e0
BLAKE2b-256 8fa4b29917b6f40c5aea362594d3d37b9d9c25def426c2a234cd1bca7c743c26

See more details on using hashes here.

Supported by

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