Added basic thing description to root
This commit is contained in:
parent
d52453849c
commit
f2af359b8b
24 changed files with 677 additions and 183 deletions
|
|
@ -1,6 +1,7 @@
|
|||
__all__ = [
|
||||
"taskify",
|
||||
"tasks",
|
||||
"dict",
|
||||
"states",
|
||||
"current_task",
|
||||
"update_task_progress",
|
||||
|
|
@ -12,6 +13,7 @@ __all__ = [
|
|||
|
||||
from .pool import (
|
||||
tasks,
|
||||
dict,
|
||||
states,
|
||||
current_task,
|
||||
update_task_progress,
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@ from .thread import TaskThread
|
|||
|
||||
from flask import copy_current_request_context
|
||||
|
||||
|
||||
class TaskMaster:
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._tasks = []
|
||||
|
||||
@property
|
||||
def tasks(self):
|
||||
"""
|
||||
Returns:
|
||||
list: List of TaskThread objects.
|
||||
"""
|
||||
return self._tasks
|
||||
|
||||
@property
|
||||
def dict(self):
|
||||
"""
|
||||
Returns:
|
||||
dict: Dictionary of TaskThread objects. Key is TaskThread ID.
|
||||
|
|
@ -28,7 +37,9 @@ class TaskMaster:
|
|||
|
||||
def new(self, f, *args, **kwargs):
|
||||
# copy_current_request_context allows threads to access flask current_app
|
||||
task = TaskThread(target=copy_current_request_context(f), args=args, kwargs=kwargs)
|
||||
task = TaskThread(
|
||||
target=copy_current_request_context(f), args=args, kwargs=kwargs
|
||||
)
|
||||
self._tasks.append(task)
|
||||
return task
|
||||
|
||||
|
|
@ -47,13 +58,23 @@ class TaskMaster:
|
|||
|
||||
|
||||
def tasks():
|
||||
"""
|
||||
List of tasks in default taskmaster
|
||||
Returns:
|
||||
list: List of tasks in default taskmaster
|
||||
"""
|
||||
global _default_task_master
|
||||
return _default_task_master.tasks
|
||||
|
||||
|
||||
def dict():
|
||||
"""
|
||||
Dictionary of tasks in default taskmaster
|
||||
Returns:
|
||||
dict: Dictionary of tasks in default taskmaster
|
||||
"""
|
||||
global _default_task_master
|
||||
return _default_task_master.tasks
|
||||
return _default_task_master.dict
|
||||
|
||||
|
||||
def states():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue