Skip to content

alive? vs finished? vs status #289

Answered by ioquatix
j-manu asked this question in Q&A
Discussion options

You must be logged in to vote

Generally speaking, the only interface you should depend on is wait. finished? relates to whether that part of the task tree has finished executing, including all children.

  1. alive? is false if the fiber does not exist yet or has completed execution:

    async/lib/async/task.rb

    Lines 117 to 120 in ffd019d

    # Whether the internal fiber is alive, i.e. it
    def alive?
    @fiber&.alive?
    end
    note that @fiber starts out as nil.
  2. Yes, that's correct. There is a diagram here that should help: https://socketry.github.io/async/guides/asynchronous-tasks/index#task-lifecycle

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@j-manu
Comment options

Answer selected by j-manu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants