I need to let a GenServer monitor a task, thus, I do:
GenServer.call(server_pid, {:monitor_task, self()})
in server:
def handle_call({:monitor_task, task_pid}, _from, state) do
ref = Process.monitor(task_pid)
{:reply, ref, state}
end
however, I get error:
** (stop) exited in: GenServer.call(#PID<0.768.0>, {:monitor_task, #PID<0.849.0>}, 5000)
** (EXIT) bad return value: :ok
Any idea?
The handle_info callbacks with calls to Logger need to return {:noreply, state} or {:stop, reason, state}, but the calls to Logger return :ok, which is an invalid return value for the callback, and is what caused the error you are seeing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With