File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11__all__ = [
22 "Pool" ,
33 "current_task" ,
4+ "current_task_stopped" ,
45 "update_task_progress" ,
56 "update_task_data" ,
67 "TaskKillException" ,
1011from .pool import (
1112 Pool ,
1213 current_task ,
14+ current_task_stopped ,
1315 update_task_progress ,
1416 update_task_data ,
1517)
Original file line number Diff line number Diff line change @@ -88,6 +88,20 @@ def current_task():
8888 return current_task_thread
8989
9090
91+ def current_task_stopped ():
92+ """Return True if the current task is stoppable and flagged to be stopped
93+
94+ If this function is called from outside a Task thread, it will return None.
95+
96+ Returns:
97+ bool -- Is the current task scheduled to be stopped
98+ """
99+ current_task_thread = threading .current_thread ()
100+ if not isinstance (current_task_thread , TaskThread ):
101+ return None
102+ return current_task_thread .stopped
103+
104+
91105def update_task_progress (progress : int ):
92106 """Update the progress of the Task in which the caller is currently running.
93107
You can’t perform that action at this time.
0 commit comments