multiprocess and multithread functional programming library
Project description
Processional
This module brings the ease and clearity of functionnal programming into the world of multiprocessing and multithreading in Python
The name stands for functIONNAL multiPROCESSing
motivations
The project goals are basically:
- calling a function in a separate thread should be as easy as calling it in the current thread
- calling a function in a separate process should be as easy as calling it in a thread
Starting with notorious alternatives, from a user perspective:
multiprocessing
,mpi
and other multiprocessing tools are not functionnal style- can only run a file or a module passed, no random tasks
- several code lines are needed to spawn processes
- and a lot needs to be done to synchronize and communicate and stop them properly
threading
and other threading tools are not functionnal style- can only run one function, no random tasks
- ignore any returned result or raised exception
- a lot needs to be done to synchronize threads tasks and to stop them properly
grpc
or similar remote process call systems bring a lot of friction- allows only certain date types to be passed between processes
- needs a lot of work to wrap functions from server side
multiprocessing
performances are unsatisfying- slow to spawn threads
- often wastes RAM
- needs a server process to manage pipes and shared memories
processional
aims to bring an answer to these problems using the functionnal and asynchronous programming paradigms and the dynamic languages features
- tasks sent to threads or processes are regular python functions (lambdas, methods, etc)
- tasks can as easily be blocking or background for the master sending the orders
- every tasks report its return value and exceptions
- slaves (threads or processes) are considered as ressources and by default cleaned and stopped when their master drops their reference
- any picklable object can be passed between processes, serialization and shared memory are nicely working together
- proxy objects allows to wrap remote process objects and their methods with no declarations
- the library is very powerfull with only few user functions
Since Colesbury brought a solution to the GIL , splitting a python program across processes to acheive parallelism will soon no longer be required, so this module will loose a bit of its interest. Anyway this library also features threads, and parallelism is not the only reason of multiprocessing so this project does not seem vain.
example
TODO
security
While multiprocessing, this library uses pickle
to send objects between processes and thus TRUST the remote side completely. Do not use this library to control tasks on a remote machine you do not trust.
Since SSL tunelling is not yet implemented here, do not use this library either if the communication between processes can be intercepted (network or OS)
Basically this library is meant to be used when all processes remote or not are communicating in a secured and closed environment, just like components in one computer.
compatiblity
Feature | Unix Python >= 3.8 |
Windows Python >= 3.8 |
---|---|---|
threads with results | X | X |
slave threads | X | X |
interruptible threads | X | X |
slave process | X | |
server process through tcp/ip (local or remote | X | X |
server process through unix sockets (faster) | X | |
shared memory | X |
maturity
This project in its published version has only been tested on small applications. However one of its previous and less complete version had been running programs with ~20 threads and ~10 processes exchanging very frequently all the time (big images, complex data structures, etc) on an industrial machine for over 2 years with no issue.
thanks
All this is made possible by
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file processional-0.1.0.tar.gz
.
File metadata
- Download URL: processional-0.1.0.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0.dev0 CPython/3.11.2 Linux/6.1.0-26-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b72e76ceef5ff9aa160c8e130fde538c69077ddb17524005cabbe52d50170d6 |
|
MD5 | c94459235842d9a4e8511b1d5cd630e8 |
|
BLAKE2b-256 | 6e7c84a9cb36f48c9e6258b07b102337880d182124b6408c9d60fea475298742 |
File details
Details for the file processional-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: processional-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0.dev0 CPython/3.11.2 Linux/6.1.0-26-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f875e28e318f85b63d7d42e8d7cc306c97fea8f3d88a9e2f9c5ac34cc0a86446 |
|
MD5 | ae4146eba7a559d1fa045c514aa37853 |
|
BLAKE2b-256 | 7e64b6b9d6e2e540fb4ad32b1049662ea090bfa03531b898591a94ca0cc7f18b |