MultiRunnable
| OS | Building Status | Coverage Status |
|---|---|---|
| Linux / MacOS | ||
| Windows |
A Python library integrates the APIs of 3 strategies (Parallel, Concurrent, Coroutine) via 4 libraries (multiprocessing, threading, gevent, asyncio) to help developers build parallelism humanly.
Overview | Quickly Start | Syntactic Sugar in MultiRunnable | Documentation | Code Example
Overview
Package 'multirunnable' is a library which could easily build a parallelism with different running strategy by mode option. Currently, it has 4 options could use: Parallel, Concurrent, GreenThread and Asynchronous.
Here's an example which builds parallelism as concurrent with multirunnable:
from multirunnable import SimpleExecutor, RunningMode
import time
Workers_Number = 5
def function(index):
print(f"This is function with index {index}")
time.sleep(3)
if __name__ == '__main__':
executor = SimpleExecutor(mode=RunningMode.Concurrent, executors=Workers_Number)
executor.run(function=function, args={"index": f"test_arg"})
How about parallel? Only one thing you need to do: change the mode.
... # Any code is the same
executor = SimpleExecutor(mode=RunningMode.Parallel, executors=Workers_Number)
... # Any code is the same
Program would turn to run as parallel and work finely.
Want change to use other way to run? Change the Running Mode, that's all.
⚠️ Parallel, Concurrent and GreenThread are in common but Asynchronous isn't.
From above all, we could change the mode to run the code as the running strategy we configure. However, it only accepts 'awaitable' function to run as asynchronous in Python. In the other word, you must remember add keyword 'async' before function which is the target to run with multirunnable.
Quickly Start
Install this package by pip:
pip install multirunnable
Write a simple code to run it.
>>> from multirunnable import SimpleExecutor, RunningMode
>>> executor = SimpleExecutor(mode=RunningMode.Parallel, executors=3)
>>> def function(index):
... print(f"This is function with index {index}")
...
>>> executor.run(function=function, args={"index": f"test_param"})
This is function with index test_param
This is function with index test_param
This is function with index test_param
>>>
Syntactic Sugar in MultiRunnable
It could use some features via Python decorator in MultiRunnable.
Following code is a demonstration about usage with Lock via decorator RunWith (it's AsyncRunWith with Asynchronous):
from multirunnable.api import RunWith
import time
@RunWith.Lock
def lock_function():
print("Running process in lock and will sleep 2 seconds.")
time.sleep(2)
✨👀 All below features support decorator:
Lock, RLock, Semaphore, Bounded Semaphore.
Documentation
The documentation contains more details, and examples.
- Quickly Start to develop parallelism with MultiRunnable
- Detail MultiRunnable usage information of functions, classes and methods in API References.
- Be curious about how to join and develop MultiRunnable? Development Documentation could be a good guide for you.
Download
MultiRunnable still a young open source which keep growing. Here's its download state:
Metadata
Release files for MultiRunnable 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| MultiRunnable-0.17.0.tar.gz | 117.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| MultiRunnable-0.17.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 278.1 kB
Release files / MultiRunnable-0.17.0.tar.gz
| Download URL | MultiRunnable-0.17.0.tar.gz |
|---|---|
| Size | 117.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ec165d9d70ac2f3ec19e4ddeda435230cefc5f4162ec5d4b05e4e0728e56b4a
|
|
BLAKE2b-256 checksum How to use checksums |
f3dca7764ad0e85e2c0c09e7ae45a6ea7ac7ab0e23b4365d053fd1edf91a6690
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / MultiRunnable-0.17.0-py3-none-any.whl
| Download URL | MultiRunnable-0.17.0-py3-none-any.whl |
|---|---|
| Size | 160.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd265f87d7298e9b76a462728aa0c9ab35958e05bd3a74b4f794684e9bb31732
|
|
BLAKE2b-256 checksum How to use checksums |
e002deb3ef9aae3f3d690efab5ef8cf464b0dbae82f58ad31822dbb35484a3e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Security for MultiRunnable 0.17.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.