:shutdown option not working properly on Task.Supervisor

I have a Task.Supervisor like this:

  def start_link() do
    Task.Supervisor.start_link(name: __MODULE__)
  end

  def child_spec(_) do
    %{
      id: __MODULE__,
      start: {__MODULE__, :start_link, []},
      type: :supervisor,
      strategy: :one_for_one
    }
  end

  def retrieve_room_data(shutdown_time) do
    Task.Supervisor.start_child(__MODULE__, &Room.retrieve_data/0, shutdown: shutdown_time)
  end

But it is not shuting down the task even if Room.retrieve_data/0 takes longer than shutdown_time.

Did I misunderstood something about the shutdown option?

shutdown_time doesn’t mean “time after which process will shut down” but “time that process have to cleanly shut down”. In other words, until supervisor will be told to shut down given child, the shutdown_time is not used at all.

2 Likes