Skip to main content

A simple async, android compatible(, atm not thread safe) process pool implementation including a (mostly) `concurrent.futures.Executor` / `concurrent.futures.ProcessPoolExecutor` compliant `Executor`.

Project description

aio_process_pool

PyPI - Version PyPI - Python Version


A simple async, android compatible (,not thread safe) process pool implementation including a (mostly) concurrent.futures.Executor / concurrent.futures.ProcessPoolExecutor compliant Executor.

Table of Contents

Installation

pip install aio_process_pool

Usage

from aio_process_pool import ProcessPool, Executor

pool = ProcessPool()
executor = Executor()

def foo(x):
    return x

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))

pool.shutdown()
executor.shutdown()

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():
    exe = Executor()
    await exe.map_async(fib_wrapper, range(45))
    exe.shutdown()

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.5.tar.gz (5.6 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.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aio_process_pool-0.0.5.tar.gz
Algorithm Hash digest
SHA256 64297376bbe139d44250a99e36d12465dbeac35663a8687d4446763c40c0e121
MD5 7f17916f3c4823410e841a1218486c1f
BLAKE2b-256 d78df5ef4c3e01f423e465e4b58f1b62469275670d5fda1ea9a3466ebd666e23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aio_process_pool-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 495416fa1daf2f17ab3dc8452ece065d35d017f59e3f1a82895822d4428aa910
MD5 a0ef3920fc586a5a05afca05e9db2524
BLAKE2b-256 a6c1590bf2f4e5845a159a6dca397e505313cdc9fe422d1710c84a890f4d5fdc

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