CyclicTask
Allow a task to be executed regulary
Table of content
Installation
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.
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.
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.
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.
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()
Metadata
Release files for CyclicTask 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 | |
|---|---|---|---|
| CyclicTask-0.1.4.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| CyclicTask-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / CyclicTask-0.1.4.tar.gz
| Download URL | CyclicTask-0.1.4.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99b73285cc2fa078957de43695a43ae528053bc96c4310a2c182975374234143
|
|
BLAKE2b-256 checksum How to use checksums |
85e24f7f6fc3757529fa120f0f8b530d9259631fcb7d38d2d24b113952852962
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
|
Release files / CyclicTask-0.1.4-py3-none-any.whl
| Download URL | CyclicTask-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ddf515e2c8c0d0592ac30d73bd292d7627bf5d150f77221118024c14e577214
|
|
BLAKE2b-256 checksum How to use checksums |
031b226cb03b658782fa4877099c2c9f10a945d179571dadd0eb0bdc882dac31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
|