parallelism
Unlock advanced task scheduling in Python with parallelism.
Seamlessly coordinate parallel and concurrent execution, optimizing performance while ensuring code integrity.
Embrace expert scheduling techniques to elevate your programming to new heights of efficiency and responsiveness.
Installation
You can install this package using pip:
pip install parallelism
Basic Usage
Explore an effortless approach to task creation and management. Follow these steps to get started:
- Import the necessary classes and functions in your Python code.
# Built-in modules
from multiprocessing import Process
from threading import Thread
# Third-party libraries
from parallelism import scheduled_task, task_scheduler
- Define your task functions. These user-defined functions will be executed in parallel and concurrently.
def func(*args, **kwargs):
if not args and not kwargs:
raise ValueError('Missing *args or **kwargs')
return args, kwargs
- Create task instances using the
scheduled_taskfunction, specifying the execution unit (Process or Thread), task name, function, and provide any required positional or keyword arguments.
task1 = scheduled_task(Process, 'task1', func, args=(1, 2, 3), continual=True)
task2 = scheduled_task(Process, 'task2', func, kwargs={'a': 10, 'b': 20}, continual=True)
task3 = scheduled_task(Thread, 'task3', func, continual=True)
- Schedule tasks using the
task_schedulerfunction, Specify the tasks to be executed along with the desired number of processes and threads.
result = task_scheduler(tasks=(task1, task2, task3), processes=2, threads=4)
- Access task execution details and results through the result object, providing insights into execution times, elapsed times, exceptions, and return values:
>>> result.execution_time
{
'task1': datetime.datetime(%Y, %m, %d, %H, %M, %S, %f),
'task2': datetime.datetime(%Y, %m, %d, %H, %M, %S, %f),
'task3': datetime.datetime(%Y, %m, %d, %H, %M, %S, %f),
}
>>> result.elapsed_time
{
'task1': float(...),
'task2': float(...),
'task3': float(...),
}
>>> result.raise_exception
{
'task3': ValueError('Missing *args or **kwargs'),
}
>>> result.return_value
{
'task1': ((1, 2, 3), {}),
'task2': ((), {'a': 10, 'b': 20}),
}
For more comprehensive documentation and advanced usage, please refer to the full API Documentation.
Metadata
Release files for parallelism 0.1.4
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 | |
|---|---|---|---|---|
| parallelism-0.1.4.tar.gz | 21.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| parallelism-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.2 kB
Release files / parallelism-0.1.4.tar.gz
| Download URL | parallelism-0.1.4.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a751d6206fc90f5903566fe19bbcb2d20bb3bafd4237630ad921804a5970c303
|
|
BLAKE2b-256 checksum How to use checksums |
4c1a2d0cc085b1d24d8b1049b3d8c8e959c2742421b44fddecb789bcc5336177
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / parallelism-0.1.4-py3-none-any.whl
| Download URL | parallelism-0.1.4-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d97bd8c5b6062a4cf5b59a01acbfe26b3f1a8450277782f326bc5b781413f427
|
|
BLAKE2b-256 checksum How to use checksums |
8299f2e5cba4c730e681baa3ed93d198cf1ab0ba18e810cff4d2680d67ed0b5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for parallelism 0.1.4
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.