Skip to main content

Provides tools for multiprocessing.

Project description

procnexus

Provides tools for multiprocessing.

procnexus offers a tiny, explicit interface for collecting function calls and executing them concurrently with Python's multiprocessing.Pool.

Installation

$ pip install procnexus

Requirements


Features

  • Simple task submission (submit) API.
  • Batch execution with process pools.
  • Ordered results (same order as submitted tasks).
  • Lightweight wrapper around the standard library.

Quick Start

from procnexus import nexus

def add(a: int, b: int) -> int:
    return a + b

job = nexus(add, processes=4)
job.submit(1, 2)
job.submit(10, 5)
job.submit(-1, 8)

results = job.run()
print(results)  # [3, 15, 7]

API

nexus(func, processes=-1) -> ProcNexus

Create a ProcNexus runner from a callable.

  • func: target function for each task.
  • processes: worker-process setting.
    • < 0: use os.cpu_count().
    • = 0: do not create a process pool; run with normal in-process mapping.
    • > 0: pass directly to multiprocessing.Pool.

ProcNexus.submit(*args, **kwargs) -> None

Queue one invocation of func.

ProcNexus.run() -> list

Execute all queued tasks in parallel and return results in submission order.

Notes

  • The submitted callable should be picklable by multiprocessing.
  • Arguments must also be serializable for inter-process communication.
  • Exceptions from worker processes propagate when calling run().

See Also

Github repository

PyPI project

License

This project falls under the BSD 3-Clause License.

History

v0.0.0

  • Initial release.

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

procnexus-0.0.0.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.

procnexus-0.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file procnexus-0.0.0.tar.gz.

File metadata

  • Download URL: procnexus-0.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for procnexus-0.0.0.tar.gz
Algorithm Hash digest
SHA256 c06ba4a1bfcf140435969ea2e5d089a369953c792d382ea36a58032144bd724e
MD5 6d106df5db3d6b3002b0f20ef597dbc6
BLAKE2b-256 a4272ee5c560ef21a4a2833864f9b6c63db5142593e83204897ed1594203e860

See more details on using hashes here.

File details

Details for the file procnexus-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: procnexus-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for procnexus-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caa45a9ffa3fb01ab91dea492e1a570d2f7ac5af7fddeff3e8c1b4312e98c159
MD5 35b12d42772e592723b349a4b984e344
BLAKE2b-256 ef66b3e030bba773303f325d9b13cef3ce30edd96a079ea6cef97d39a1041e1b

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