Registry / workflow / pathos

pathos

JSON →
library0.3.5pypypi✓ verified 49d ago

pathos is a framework for heterogeneous computing that provides tools for parallel graph management and execution. It offers a consistent high-level interface for configuring and launching parallel computations across diverse resources, aiming to extend user code to parallel and distributed computing with minimal refactoring. The library is currently at version 0.3.5 and has a consistent release cadence with minor versions released every few months, typically adding incremental features and dependency updates.

workflowdevops
pip install pathos
Install & Compatibility
Where this runs
tested against v0.3.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.248s · 21MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.9s · import 0.238s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ProcessingPool
from pathos.multiprocessing import ProcessingPool as Pool
from multiprocessing import Pool
While 'pathos.multiprocessing' is an extension of Python's built-in 'multiprocessing', direct import from 'multiprocessing' will lack pathos's enhancements like advanced serialization and multi-argument map support. The 'as Pool' alias is common practice for brevity.
ParallelPool
from pathos.pools import ParallelPool
This provides a convenient interface for creating a pool of worker processes, similar to ProcessingPool.

This example demonstrates how to use `pathos.multiprocessing.ProcessingPool` to parallelize a function with multiple arguments using its enhanced `map` method. The `nodes` parameter configures the number of worker processes. Ensure the `if __name__ == '__main__':` block is used for multiprocessing compatibility.

from pathos.multiprocessing import ProcessingPool as Pool def calculate_power(base, exponent): return base ** exponent if __name__ == '__main__': bases = [1, 2, 3, 4, 5] exponents = [2, 3, 2, 4, 3] # Initialize a pool with a number of worker processes (e.g., 4) pool = Pool(nodes=4) # Use the map method to apply calculate_power in parallel # pathos's map directly accepts multiple iterables for multiple arguments results = pool.map(calculate_power, bases, exponents) print(f"Bases: {bases}") print(f"Exponents: {exponents}") print(f"Parallel Results: {results}") # Don't forget to close and join the pool when done pool.close() pool.join()
Debug
Known issues
breakingThe minimum required Python version for `pathos` has progressively increased. As of version 0.3.5, Python 3.9 or newer is required.
fix
Upgrade your Python environment to version 3.9 or higher. For compatibility with older Python versions, install an earlier `pathos` release (e.g., `pip install 'pathos<0.3.5'` for Python 3.8, or `pip install 'pathos<0.3.1'` for Python 3.7).
affects: 0.3.5+
gotchaWhen using `pathos.multiprocessing.ProcessingPool`, objects passed to worker processes are *copied* (serialized and deserialized) rather than shared in memory. This means modifications to these objects within a worker process will not reflect in the original object in the parent process or other workers.
fix
Design your parallel functions to return explicit results from worker processes. If shared mutable state is absolutely necessary, consider using `multiprocess.Manager` objects (e.g., `Manager().dict()`, `Manager().list()`) or explicit inter-process communication mechanisms like queues or pipes, understanding their inherent overhead.
affects: All versions
gotcha`pathos`'s `map` methods (e.g., `ProcessingPool.map`) directly accept multiple iterables as arguments for functions with multiple parameters, which differs from the standard `multiprocessing.Pool.map` signature that expects a single iterable of arguments. Users accustomed to `multiprocessing` might attempt workarounds like `itertools.starmap` or tuple unpacking in the target function, which are unnecessary and potentially less efficient with `pathos`.
fix
Pass each argument iterable as a separate argument to the `pool.map()` call. For a function `f(a, b)`, you can call `pool.map(f, iterable_a, iterable_b)` directly, where `iterable_a` and `iterable_b` are sequences of arguments for `a` and `b` respectively.
affects: All versions
gotcha`pathos` leverages `dill` for object serialization, which is significantly more powerful than Python's default `pickle` used by standard `multiprocessing`. This allows `pathos` to reliably serialize and transfer complex objects, lambda functions, nested functions, and class methods to worker processes, which often cause `PicklingError` exceptions with plain `multiprocessing`.
fix
This is a feature of `pathos` that solves a common `multiprocessing` problem. If you encounter serialization issues with standard `multiprocessing`, `pathos` is designed to handle such complex objects transparently. Ensure `dill` is correctly installed and `pathos`'s pool implementations are utilized.
affects: All versions
Errors
Common errors & fixes
Can't pickle local object
This error or '_pickle.PicklingError' often occurs when pathos's multiprocessing falls back to Python's standard pickle module, which cannot serialize complex objects like local functions, lambda functions, or class methods, instead of using its more powerful dill serializer via multiprocess. This can happen if multiprocess is not correctly installed or compiled.
fix
Ensure `dill` and `multiprocess` are correctly installed: `pip install dill multiprocess`. On Windows, a C++ compiler might be required for `multiprocess` to compile correctly. Explicitly import from `pathos.multiprocessing` (e.g., `from pathos.multiprocessing import ProcessingPool`). If passing class methods, define them at the top level of a module or make them static/class methods.
ModuleNotFoundError: No module named 'pathos.multiprocessing'
This error (or `ImportError` for older Python versions) indicates that the `pathos` library or its `multiprocess` dependency is not installed correctly, or an older version is being used where the module path was different.
fix
Install `pathos` and its dependencies using pip: `pip install pathos`. If issues persist, try upgrading setuptools (`pip install --upgrade setuptools`) then reinstalling `pathos`. Also, ensure that `multiprocess` and `dill` are explicitly installed: `pip install multiprocess dill`.
ImportError: sys.meta_path is None, Python is likely shutting down
This error often occurs when a `pathos` pool (especially `ProcessPool`) is used within a `with` statement, and Python attempts to shut down processes while resources are still being accessed or cleaned up, leading to issues with module imports during interpreter shutdown.
fix
Manually manage the pool lifecycle by calling `pool.close()` and `pool.join()` explicitly after the parallel computation is complete, instead of solely relying on the `with` statement's implicit exit.
Upgrade
Version history
0.3.5latest on PyPI
Audit
Dependencies
pythonrequiredRuntime requirement
dillrequiredAdvanced serialization for objects and functions
poxrequiredUtilities for filesystem exploration and automated builds
ppftrequiredDistributed and parallel Python
multiprocessrequiredEnhanced multiprocessing and multithreading capabilities
Agent activity
98 hits · last 30 days
node
8
petalbot
5
seranking-bot
4
ahrefsbot
2
googlebot
1
Resources