You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basic_usage/action_tasks.rst
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,25 +17,24 @@ All Actions will return a serialized representation of the task, when your POST
17
17
18
18
Most users will not need to create instances of this class. Instead, they will be created automatically when a function is started by an API Action view.
19
19
20
-
.. autoclass:: labthings.tasks.TaskThread
20
+
.. autoclass:: labthings.actions.ActionThread
21
21
:members:
22
22
23
+
Accessing the current action thread
24
+
+++++++++++++++++++++++++++++++++++
23
25
24
-
Accessing the current task
25
-
++++++++++++++++++++++++++
26
+
A function running inside a :class:`labthings.actions.ActionThread` is able to access the instance it is running in using the :meth:`labthings.current_action` function. This allows the state of the Action to be modified freely.
26
27
27
-
A function running inside a :class:`labthings.tasks.TaskThread` is able to access the instance it is running in using the :meth:`labthings.current_task` function. This allows the state of the Action to be modified freely.
28
-
29
-
.. autofunction:: labthings.current_task
28
+
.. autofunction:: labthings.current_action
30
29
:noindex:
31
30
32
31
33
-
Updating task progress
34
-
++++++++++++++++++++++
32
+
Updating action progress
33
+
++++++++++++++++++++++++
35
34
36
-
Some client applications may be able to display progress bars showing the progress of an action. Implementing progress updates in your actions is made easy with the :py:meth:`labthings.update_task_progress` function. This function takes a single argument, which is the action progress as an integer percent (0 - 100).
35
+
Some client applications may be able to display progress bars showing the progress of an action. Implementing progress updates in your actions is made easy with the :py:meth:`labthings.update_action_progress` function. This function takes a single argument, which is the action progress as an integer percent (0 - 100).
37
36
38
37
If your long running function was started within a background task, this function will update the state of the corresponding action object. If your function is called outside of a long-running task (e.g. by some internal code, not the web API), then this function will silently do nothing.
0 commit comments