@@ -43,18 +43,28 @@ class AsyncActionNode(StatefulActionNode):
4343 """
4444
4545 def __init__ (self , name , config ):
46+ """
47+ Initialize the AsyncActionNode with the given name and configuration.
48+ """
4649 super ().__init__ (name , config )
4750
4851 def on_start (self ) -> NodeStatus :
52+ """
53+ Initialize the coroutine and return RUNNING status.
54+ """
4955 self .coroutine = self .run ()
5056 return NodeStatus .RUNNING
5157
5258 def on_running (self ) -> NodeStatus :
59+ """
60+ Resume the coroutine (generator). As long as the generator is not
61+ exhausted, keep this action in the RUNNING state.
62+ """
5363 # The library logic should never allow this to happen, but users can
5464 # still manually call `on_running` without an associated `on_start`
5565 # call. Make sure to print a useful error when this happens.
5666 if self .coroutine is None :
57- raise "AsyncActionNode run without starting"
67+ raise ValueError ( "AsyncActionNode run without starting" )
5868
5969 # Resume the coroutine (generator). As long as the generator is not
6070 # exhausted, keep this action in the RUNNING state.
@@ -70,6 +80,9 @@ def on_running(self) -> NodeStatus:
7080 return NodeStatus .SUCCESS
7181
7282 def on_halted (self ):
83+ """
84+ What to do when the action is halted. Does nothing by default.
85+ """
7386 # Default action: do nothing
7487 pass
7588
0 commit comments