lib/async/task.rb in async-2.8.2 vs lib/async/task.rb in async-2.9.0

- old
+ new

@@ -206,10 +206,10 @@ # If `later` is false, it means that `stop` has been invoked directly. When `later` is true, it means that `stop` is invoked by `stop_children` or some other indirect mechanism. In that case, if we encounter the "current" fiber, we can't stop it right away, as it's currently performing `#stop`. Stopping it immediately would interrupt the current stop traversal, so we need to schedule the stop to occur later. # # @parameter later [Boolean] Whether to stop the task later, or immediately. def stop(later = false) if self.stopped? - # If we already stopped this task... don't try to stop it again: + # If the task is already stopped, a `stop` state transition re-enters the same state which is a no-op. However, we will also attempt to stop any running children too. This can happen if the children did not stop correctly the first time around. Doing this should probably be considered a bug, but it's better to be safe than sorry. return stopped! end # If the fiber is alive, we need to stop it: if @fiber&.alive?