parallelism


Nameparallelism JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryEfficient parallel task scheduling and concurrency management
upload_time2023-08-13 20:48:02
maintainer
docs_urlNone
authorIdan Hazan
requires_python>=3.8
licenseMIT
keywords parallelism parallel concurrency concurrent scheduled scheduling scheduler task multitasking process multiprocessing thread multithreading
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
pip install parallelism
```

## Basic Usage

Explore an effortless approach to task creation and management.
Follow these steps to get started:

1. Import the necessary classes and functions in your Python code.

  ```python
  # Built-in modules
  from multiprocessing import Process
  from threading import Thread

  # Third-party libraries
  from parallelism import scheduled_task, task_scheduler
  ```

2. Define your task functions. These user-defined functions will be executed in parallel and concurrently.

```python
def func(*args, **kwargs):
    if not args and not kwargs:
        raise ValueError('Missing *args or **kwargs')
    return args, kwargs
```

3. Create task instances using the `scheduled_task` function, specifying the execution unit (Process or Thread), task name, function, and provide any required positional or keyword arguments.

```python
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)
```

4. Schedule tasks using the `task_scheduler` function, Specify the tasks to be executed along with the desired number of processes and threads.

```python
result = task_scheduler(tasks=(task1, task2, task3), processes=2, threads=4)
```

5. Access task execution details and results through the result object, providing insights into execution times, elapsed times, exceptions, and return values:

```python
>>> 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](https://parallelism.readthedocs.io/en/latest/index.html).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "parallelism",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "parallelism,parallel,concurrency,concurrent,scheduled,scheduling,scheduler,task,multitasking,process,multiprocessing,thread,multithreading",
    "author": "Idan Hazan",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/4c/1a/2d0cc085b1d24d8b1049b3d8c8e959c2742421b44fddecb789bcc5336177/parallelism-0.1.4.tar.gz",
    "platform": null,
    "description": "# parallelism\r\n\r\nUnlock advanced task scheduling in Python with `parallelism`.\r\nSeamlessly coordinate parallel and concurrent execution, optimizing performance while ensuring code integrity.\r\nEmbrace expert scheduling techniques to elevate your programming to new heights of efficiency and responsiveness.\r\n\r\n## Installation\r\n\r\nYou can install this package using pip:\r\n\r\n```bash\r\npip install parallelism\r\n```\r\n\r\n## Basic Usage\r\n\r\nExplore an effortless approach to task creation and management.\r\nFollow these steps to get started:\r\n\r\n1. Import the necessary classes and functions in your Python code.\r\n\r\n  ```python\r\n  # Built-in modules\r\n  from multiprocessing import Process\r\n  from threading import Thread\r\n\r\n  # Third-party libraries\r\n  from parallelism import scheduled_task, task_scheduler\r\n  ```\r\n\r\n2. Define your task functions. These user-defined functions will be executed in parallel and concurrently.\r\n\r\n```python\r\ndef func(*args, **kwargs):\r\n    if not args and not kwargs:\r\n        raise ValueError('Missing *args or **kwargs')\r\n    return args, kwargs\r\n```\r\n\r\n3. Create task instances using the `scheduled_task` function, specifying the execution unit (Process or Thread), task name, function, and provide any required positional or keyword arguments.\r\n\r\n```python\r\ntask1 = scheduled_task(Process, 'task1', func, args=(1, 2, 3), continual=True)\r\ntask2 = scheduled_task(Process, 'task2', func, kwargs={'a': 10, 'b': 20}, continual=True)\r\ntask3 = scheduled_task(Thread, 'task3', func, continual=True)\r\n```\r\n\r\n4. Schedule tasks using the `task_scheduler` function, Specify the tasks to be executed along with the desired number of processes and threads.\r\n\r\n```python\r\nresult = task_scheduler(tasks=(task1, task2, task3), processes=2, threads=4)\r\n```\r\n\r\n5. Access task execution details and results through the result object, providing insights into execution times, elapsed times, exceptions, and return values:\r\n\r\n```python\r\n>>> result.execution_time\r\n{\r\n    'task1': datetime.datetime(%Y, %m, %d, %H, %M, %S, %f),\r\n    'task2': datetime.datetime(%Y, %m, %d, %H, %M, %S, %f),\r\n    'task3': datetime.datetime(%Y, %m, %d, %H, %M, %S, %f),\r\n}\r\n>>> result.elapsed_time\r\n{\r\n    'task1': float(...),\r\n    'task2': float(...),\r\n    'task3': float(...),\r\n}\r\n>>> result.raise_exception\r\n{\r\n    'task3': ValueError('Missing *args or **kwargs'),\r\n}\r\n>>> result.return_value\r\n{\r\n    'task1': ((1, 2, 3), {}),\r\n    'task2': ((), {'a': 10, 'b': 20}),\r\n}\r\n```\r\n\r\nFor more comprehensive documentation and advanced usage, please refer to the full [API Documentation](https://parallelism.readthedocs.io/en/latest/index.html).\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Efficient parallel task scheduling and concurrency management",
    "version": "0.1.4",
    "project_urls": {
        "documentation": "https://parallelism.readthedocs.io",
        "homepage": "https://github.com/idanhazan/parallelism",
        "repository": "https://github.com/idanhazan/parallelism"
    },
    "split_keywords": [
        "parallelism",
        "parallel",
        "concurrency",
        "concurrent",
        "scheduled",
        "scheduling",
        "scheduler",
        "task",
        "multitasking",
        "process",
        "multiprocessing",
        "thread",
        "multithreading"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8299f2e5cba4c730e681baa3ed93d198cf1ab0ba18e810cff4d2680d67ed0b5c",
                "md5": "5d49ad1d3570e1c11b9989eb19b083be",
                "sha256": "d97bd8c5b6062a4cf5b59a01acbfe26b3f1a8450277782f326bc5b781413f427"
            },
            "downloads": -1,
            "filename": "parallelism-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5d49ad1d3570e1c11b9989eb19b083be",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 21471,
            "upload_time": "2023-08-13T20:48:00",
            "upload_time_iso_8601": "2023-08-13T20:48:00.691459Z",
            "url": "https://files.pythonhosted.org/packages/82/99/f2e5cba4c730e681baa3ed93d198cf1ab0ba18e810cff4d2680d67ed0b5c/parallelism-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c1a2d0cc085b1d24d8b1049b3d8c8e959c2742421b44fddecb789bcc5336177",
                "md5": "eed8ef8a0639d7a226ad5a01b6ef21a5",
                "sha256": "a751d6206fc90f5903566fe19bbcb2d20bb3bafd4237630ad921804a5970c303"
            },
            "downloads": -1,
            "filename": "parallelism-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "eed8ef8a0639d7a226ad5a01b6ef21a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 21709,
            "upload_time": "2023-08-13T20:48:02",
            "upload_time_iso_8601": "2023-08-13T20:48:02.378789Z",
            "url": "https://files.pythonhosted.org/packages/4c/1a/2d0cc085b1d24d8b1049b3d8c8e959c2742421b44fddecb789bcc5336177/parallelism-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-13 20:48:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "idanhazan",
    "github_project": "parallelism",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "parallelism"
}
        
Elapsed time: 0.10160s