CyclicTask


NameCyclicTask JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryAllow a task to be executed regulary
upload_time2024-01-07 18:58:20
maintainer
docs_urlNone
author
requires_python>=3.11
licenseMIT License Copyright (c) 2023 ThunderTecke Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords threading thread cyclic plc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![GitHub](https://img.shields.io/github/license/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/blob/develop/LICENSE)
[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/releases)
[![GitHub Release Date](https://img.shields.io/github/release-date/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/releases)
[![GitHub last commit](https://img.shields.io/github/last-commit/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/commits)
[![GitHub issues](https://img.shields.io/github/issues/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/issues)
![Python version](https://img.shields.io/badge/Python-v3.11-blue)

# CyclicTask <!-- omit in toc -->
Allow a task to be executed regulary

## Table of content <!-- omit in toc -->
- [Installation](#installation)
- [`ContinuousTask` class usage](#continuoustask-class-usage)
  - [Minimum usage](#minimum-usage)
  - [Maximum execution time](#maximum-execution-time)
- [`TimedTask` class](#timedtask-class)
  - [Minimum usage](#minimum-usage-1)
  - [Maximum execution time](#maximum-execution-time-1)

## Installation

```bash
python3 -m pip install CyclicTask
```

## `ContinuousTask` class usage
### Minimum usage

The `ContinuousTask` class allow to execute a task as fast as possible, until the stop request.

```Python
from CyclicTask.ContinuousTask import ContinuousTask

# Sub-classing `ContinuousTask` class
class Task(ContinuousTask):
    # override `task` function
    def task(self) -> None:
        # --- Task definition ---
        pass

# Task creation
task = Task()

# Task start
task.start()

# Task stop
task.stop()

# Waiting for the end of the current cycle
task.join()
```

### Maximum execution time
`maximumTime` parameter allow to monitor the execution duration of one cycle. 

If this one exceed 80% of `maximumTime` the attribut `cycleTimeWarning` is set for one cycle, and a message in the logger is written.

If the duration exceed `maximumTime` the exception `CycleTimeError` is raised, and a message is written in the logger.

```Python
from CyclicTask.ContinuousTask import ContinuousTask

# Sub-classing `ContinuousTask` class
class Task(ContinuousTask):
    # override `task` function
    def task(self) -> None:
        # --- Task definition ---
        pass

# Task creation with `maximumTime` set to 1 second
task = Task(maximumTime = 1.0)

# Task start
task.start()

# Task stop
task.stop()

# Waiting for the end of the current cycle
task.join()
```

## `TimedTask` class
### Minimum usage
The `TimedTask` class allow to execute a task every x seconds, until the stop request.

```Python
from CyclicTask.TimedTask import TimedTask

# Sub-classing `TimedTask` class
class Task(TimedTask):
    # override `task` function
    def task(task) -> None:
        # --- Task definition ---
        pass

# Task creation with `cycleTime` set to 1 second
task = Task(cycleTime = 1.0)

# Task start
task.start()

# Task stop
task.stop()

# Waiting for the end of the current cycle
task.join()
```

### Maximum execution time
`maximumTime` parameter allow to monitor the execution duration of one cycle.
If `maximumTime` is left to None, the maximum execution time is set to 150% of the cycle time.

If this one exceed 80% of `maximumTime` the attribut `cycleTimeWarning` is set for one cycle, and a message in the logger is written.

If the duration exceed `maximumTime` the exception `CycleTimeError` is raised, and a message is written in the logger.

```Python
from CyclicTask.TimedTask import TimedTask

# Sub-classing `TimedTask` class
class Task(TimedTask):
    # override `task` function
    def task(task) -> None:
        # --- Task definition ---
        pass

# Task creation with `cycleTime` set to 1 second, and `maximumTime` set to 1.0 second
task = Task(cycleTime = 1.0, maximumTime = 1.0)

# Task start
task.start()

# Task stop
task.stop()

# Waiting for the end of the current cycle
task.join()
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "CyclicTask",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "ThunderTecke <thunder.tecke@gmail.com>",
    "keywords": "Threading,Thread,Cyclic,PLC",
    "author": "",
    "author_email": "ThunderTecke <thunder.tecke@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/85/e2/4f7f6fc3757529fa120f0f8b530d9259631fcb7d38d2d24b113952852962/CyclicTask-0.1.4.tar.gz",
    "platform": null,
    "description": "[![GitHub](https://img.shields.io/github/license/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/blob/develop/LICENSE)\n[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/releases)\n[![GitHub Release Date](https://img.shields.io/github/release-date/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/releases)\n[![GitHub last commit](https://img.shields.io/github/last-commit/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/commits)\n[![GitHub issues](https://img.shields.io/github/issues/ThunderTecke/CyclicTask)](https://github.com/ThunderTecke/CyclicTask/issues)\n![Python version](https://img.shields.io/badge/Python-v3.11-blue)\n\n# CyclicTask <!-- omit in toc -->\nAllow a task to be executed regulary\n\n## Table of content <!-- omit in toc -->\n- [Installation](#installation)\n- [`ContinuousTask` class usage](#continuoustask-class-usage)\n  - [Minimum usage](#minimum-usage)\n  - [Maximum execution time](#maximum-execution-time)\n- [`TimedTask` class](#timedtask-class)\n  - [Minimum usage](#minimum-usage-1)\n  - [Maximum execution time](#maximum-execution-time-1)\n\n## Installation\n\n```bash\npython3 -m pip install CyclicTask\n```\n\n## `ContinuousTask` class usage\n### Minimum usage\n\nThe `ContinuousTask` class allow to execute a task as fast as possible, until the stop request.\n\n```Python\nfrom CyclicTask.ContinuousTask import ContinuousTask\n\n# Sub-classing `ContinuousTask` class\nclass Task(ContinuousTask):\n    # override `task` function\n    def task(self) -> None:\n        # --- Task definition ---\n        pass\n\n# Task creation\ntask = Task()\n\n# Task start\ntask.start()\n\n# Task stop\ntask.stop()\n\n# Waiting for the end of the current cycle\ntask.join()\n```\n\n### Maximum execution time\n`maximumTime` parameter allow to monitor the execution duration of one cycle. \n\nIf this one exceed 80% of `maximumTime` the attribut `cycleTimeWarning` is set for one cycle, and a message in the logger is written.\n\nIf the duration exceed `maximumTime` the exception `CycleTimeError` is raised, and a message is written in the logger.\n\n```Python\nfrom CyclicTask.ContinuousTask import ContinuousTask\n\n# Sub-classing `ContinuousTask` class\nclass Task(ContinuousTask):\n    # override `task` function\n    def task(self) -> None:\n        # --- Task definition ---\n        pass\n\n# Task creation with `maximumTime` set to 1 second\ntask = Task(maximumTime = 1.0)\n\n# Task start\ntask.start()\n\n# Task stop\ntask.stop()\n\n# Waiting for the end of the current cycle\ntask.join()\n```\n\n## `TimedTask` class\n### Minimum usage\nThe `TimedTask` class allow to execute a task every x seconds, until the stop request.\n\n```Python\nfrom CyclicTask.TimedTask import TimedTask\n\n# Sub-classing `TimedTask` class\nclass Task(TimedTask):\n    # override `task` function\n    def task(task) -> None:\n        # --- Task definition ---\n        pass\n\n# Task creation with `cycleTime` set to 1 second\ntask = Task(cycleTime = 1.0)\n\n# Task start\ntask.start()\n\n# Task stop\ntask.stop()\n\n# Waiting for the end of the current cycle\ntask.join()\n```\n\n### Maximum execution time\n`maximumTime` parameter allow to monitor the execution duration of one cycle.\nIf `maximumTime` is left to None, the maximum execution time is set to 150% of the cycle time.\n\nIf this one exceed 80% of `maximumTime` the attribut `cycleTimeWarning` is set for one cycle, and a message in the logger is written.\n\nIf the duration exceed `maximumTime` the exception `CycleTimeError` is raised, and a message is written in the logger.\n\n```Python\nfrom CyclicTask.TimedTask import TimedTask\n\n# Sub-classing `TimedTask` class\nclass Task(TimedTask):\n    # override `task` function\n    def task(task) -> None:\n        # --- Task definition ---\n        pass\n\n# Task creation with `cycleTime` set to 1 second, and `maximumTime` set to 1.0 second\ntask = Task(cycleTime = 1.0, maximumTime = 1.0)\n\n# Task start\ntask.start()\n\n# Task stop\ntask.stop()\n\n# Waiting for the end of the current cycle\ntask.join()\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 ThunderTecke  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Allow a task to be executed regulary",
    "version": "0.1.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/ThunderTecke/CyclicTask/issues",
        "Change log": "https://github.com/ThunderTecke/CyclicTask/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/ThunderTecke/CyclicTask"
    },
    "split_keywords": [
        "threading",
        "thread",
        "cyclic",
        "plc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "031b226cb03b658782fa4877099c2c9f10a945d179571dadd0eb0bdc882dac31",
                "md5": "c7295835b69bfd785b6892c1ff97f9f1",
                "sha256": "6ddf515e2c8c0d0592ac30d73bd292d7627bf5d150f77221118024c14e577214"
            },
            "downloads": -1,
            "filename": "CyclicTask-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c7295835b69bfd785b6892c1ff97f9f1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 6613,
            "upload_time": "2024-01-07T18:58:19",
            "upload_time_iso_8601": "2024-01-07T18:58:19.190790Z",
            "url": "https://files.pythonhosted.org/packages/03/1b/226cb03b658782fa4877099c2c9f10a945d179571dadd0eb0bdc882dac31/CyclicTask-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "85e24f7f6fc3757529fa120f0f8b530d9259631fcb7d38d2d24b113952852962",
                "md5": "b8497e7426d8f1ac3edcfe589356a6b9",
                "sha256": "99b73285cc2fa078957de43695a43ae528053bc96c4310a2c182975374234143"
            },
            "downloads": -1,
            "filename": "CyclicTask-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b8497e7426d8f1ac3edcfe589356a6b9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 4665,
            "upload_time": "2024-01-07T18:58:20",
            "upload_time_iso_8601": "2024-01-07T18:58:20.565312Z",
            "url": "https://files.pythonhosted.org/packages/85/e2/4f7f6fc3757529fa120f0f8b530d9259631fcb7d38d2d24b113952852962/CyclicTask-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-07 18:58:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ThunderTecke",
    "github_project": "CyclicTask",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cyclictask"
}
        
Elapsed time: 0.16402s