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.6.tar.gz (6.3 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.6-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aio_process_pool-0.0.6.tar.gz
Algorithm Hash digest
SHA256 5e8a85d825790131f5575135467c2c81d7aedf8c97aaa1d7dcac329fbe111c69
MD5 b3d53cc0dbae362e9c7a885f015d0f69
BLAKE2b-256 0138d398ba2bc8b9bb5baacf5e62614d8b578ec0c1e27361f4856c67d98aa75d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aio_process_pool-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1eb1438f8901837a84e6270b87f7dce8940548064b9bcc883479b58f733ab7fe
MD5 0d47b0bc76d4c4d5790fbe35da34a4e6
BLAKE2b-256 65d3eb0ec19db9bc9ee654e3bf360e52a52280032264f3491934869a708fcf02

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