22from functools import wraps
33
44import threading
5- from .thread import TaskThread
5+ from .thread import ActionThread
66
77
8- # TODO: Handle discarding old tasks . Action views now use deques
8+ # TODO: Handle discarding old actions . Action views now use deques
99class Pool :
1010 """ """
1111
1212 def __init__ (self ):
1313 self .threads = set ()
1414
15- def add (self , thread : TaskThread ):
15+ def add (self , thread : ActionThread ):
1616 """
1717
18- :param thread: TaskThread :
18+ :param thread: ActionThread :
1919
2020 """
2121 self .threads .add (thread )
2222
23- def start (self , thread : TaskThread ):
23+ def start (self , thread : ActionThread ):
2424 """
2525
26- :param thread: TaskThread :
26+ :param thread: ActionThread :
2727
2828 """
2929 self .add (thread )
@@ -37,7 +37,7 @@ def spawn(self, function, *args, **kwargs):
3737 :param **kwargs:
3838
3939 """
40- thread = TaskThread (target = function , args = args , kwargs = kwargs )
40+ thread = ActionThread (target = function , args = args , kwargs = kwargs )
4141 self .start (thread )
4242 return thread
4343
@@ -55,7 +55,7 @@ def tasks(self):
5555 """
5656
5757
58- :returns: List of TaskThread objects.
58+ :returns: List of ActionThread objects.
5959
6060 :rtype: list
6161
@@ -66,7 +66,7 @@ def states(self):
6666 """
6767
6868
69- :returns: Dictionary of TaskThread .state dictionaries. Key is TaskThread ID.
69+ :returns: Dictionary of ActionThread .state dictionaries. Key is ActionThread ID.
7070
7171 :rtype: dict
7272
@@ -77,7 +77,7 @@ def to_dict(self):
7777 """
7878
7979
80- :returns: Dictionary of TaskThread objects. Key is TaskThread ID.
80+ :returns: Dictionary of ActionThread objects. Key is ActionThread ID.
8181
8282 :rtype: dict
8383
@@ -117,22 +117,22 @@ def join(self):
117117# Operations on the current task
118118
119119
120- def current_task ():
121- """Return the Task instance in which the caller is currently running.
120+ def current_action ():
121+ """Return the ActionThread instance in which the caller is currently running.
122122
123- If this function is called from outside a Task thread , it will return None.
123+ If this function is called from outside an ActionThread , it will return None.
124124
125125
126- :returns: TaskThread -- Currently running Task thread .
126+ :returns: ActionThread -- Currently running ActionThread .
127127
128128 """
129- current_task_thread = threading .current_thread ()
130- if not isinstance (current_task_thread , TaskThread ):
129+ current_action_thread = threading .current_thread ()
130+ if not isinstance (current_action_thread , ActionThread ):
131131 return None
132- return current_task_thread
132+ return current_action_thread
133133
134134
135- def update_task_progress (progress : int ):
135+ def update_action_progress (progress : int ):
136136 """Update the progress of the Task in which the caller is currently running.
137137
138138 If this function is called from outside a Task thread, it will do nothing.
@@ -141,13 +141,13 @@ def update_task_progress(progress: int):
141141 :param progress: int:
142142
143143 """
144- if current_task ():
145- current_task ().update_progress (progress )
144+ if current_action ():
145+ current_action ().update_progress (progress )
146146 else :
147147 logging .info ("Cannot update task progress of __main__ thread. Skipping." )
148148
149149
150- def update_task_data (data : dict ):
150+ def update_action_data (data : dict ):
151151 """Update the data of the Task in which the caller is currently running.
152152
153153 If this function is called from outside a Task thread, it will do nothing.
@@ -156,7 +156,7 @@ def update_task_data(data: dict):
156156 :param data: dict:
157157
158158 """
159- if current_task ():
160- current_task ().update_data (data )
159+ if current_action ():
160+ current_action ().update_data (data )
161161 else :
162162 logging .info ("Cannot update task data of __main__ thread. Skipping." )
0 commit comments