Hello People, I have Supervisor that starts children dynamically with an ID {Wms.Queue.Worker.Dummy, 2} I want that child to be terminated and I am doing it with
def handle_info(:timeout, state) do
{:stop, :normal, state}
end
I’m using the option restart: :transient
so when it terminates the supervisor does not restart it, But I want to start_child manually later.
When I try to start it again it tells me
** (exit) exited in: GenServer.call(Wms.Queue.Worker.Dummy, {:terminate_child, {Wms.Queue.Worker.Dummy, 2}}, :infinity)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
(elixir) lib/gen_server.ex:999: GenServer.call/3
And it is because the children are still registered in the supervisor with a undefined PID
Supervisor.which_children(Wms.Queue.Worker.Dummy.Pool)
[
{{Wms.Queue.Worker.Dummy, 2}, :undefined, :worker, [Wms.Queue.Worker.Dummy]},
{{Wms.Queue.Worker.Dummy, 1}, :undefined, :worker, [Wms.Queue.Worker.Dummy]}
]
Could someone explain to me why the terminated child is not deleted from there, and which is the best way?