Spawn a thread that executes tasks in order
Project description
Threaded Task Executor
Allows functions to be called in a seperate thread and executed in FIFO order.
Possible Uses:
- For serial communication where send/recv order matters
- Run background tasks in tkinter easily, without freezing gui
- Any application where background tasks are required to be executed in order
Gettings Started:
Installing
pip install threaded-task-executor
Importing
from threaded_task_executor import Task_Queue, Task
How To Use
tasks = Task_Queue()
tasks.add_task(Task(print, args=("test 1")))
tasks.add_task(Task(print, args=("test 2")))
When this is run it should start the thread and execute the tasks in FIFO order.
Documentation:
Task(func, callback=None, task_name="", args=(), kwargs={})
- func : the function that will be called when executed
- callback : function that will be run when the task has started and finished
- callback("STARTED", task_name)
- callback("FINISHED", task_name)
- task_name : the name of the task
- args : tuple of arguments that will be given to the function
- kwargs : dict of keyword arguments that will be given to the function
Task_Queue(daemon=None)
- daemon : (True, False, None) : Whether main thread has to wait for thread to finish before stopping main thread
- add_task(new_task) : Adds a new task obj, if there is no threads running will start one
- get_current_task() : Allows for the current task that is executing to be returned
- tasks_left() : Returns the number of tasks left to be completed, includes currently executing task if any.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for threaded-task-executor-1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0889d47e81a67bcce1c2fea9925f63836cc44ead97b78ab7a92c7733649858e |
|
MD5 | fd15e166680c8477a2ecb93b6c7391b2 |
|
BLAKE2b-256 | c95a4eb65fa0e70d0394ac16ee1c93749660be8d0ca5a07b2124baf14b02c464 |
Close
Hashes for threaded_task_executor-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8263069c932d031f273a498abb845667535fd81dfe859103692ba21856f0b92d |
|
MD5 | 6769e3d9d8dc9c21905531de65f78ff7 |
|
BLAKE2b-256 | cc06ae286be73c4bffca82900d16ebd2eb1e53aa04f9ca68a547a45e01ae70ba |