kino icon indicating copy to clipboard operation
kino copied to clipboard

Reevaluating a cell containing Kino.start_child! sometimes errors with "Already started"

Open jyc opened this issue 1 year ago • 5 comments

Hello!

Thanks for making Kino.

I'm using some GenServers inside of a Livebook notebook. I have an Elixir cell which contains a call to Kino.start_child!/1.

Weirdly, sometimes when I reevaluate the cell, it works fine and I get #PID<0.4995.0>. Other times I get an error about a process already being started.

Do you know what's going on? Unfortunately the error is nondeterministic so I'm unable to create a minimal reproducible example, but I'm happy to help investigate.

jyc avatar Feb 13 '24 01:02 jyc

Can you provide the stacktrace as well?

Even if not consistent, can you provide the code? Or can you tell us if it happens if you have a very simple GenServer as children? The reason I ask is because when we re-execute a cell, we terminate all previous children. So I can think of two options here:

  1. Livebook has a bug
  2. Your GenServer is starting another GenServer (or another process) inside of it and that one is not terminated correctly

josevalim avatar Feb 13 '24 08:02 josevalim

Sorry for the delay! I will provide a stacktrace the next time it happens! The structure of the code looks like this:

Elixir cell 1: define a GenServer Elixir cell 2: start that GenServer using Kino.start_child!/1, assign it a name Elixir cell 3: call that GenServer by name

The GenServer does not start any other GenServers, but it does call other ones, also by name, if that matters!

jyc avatar Feb 14 '24 22:02 jyc

Do you call Kino.start_child!/1 directly in the code cell, or from within some other process?

Also, for the reference, what Kino and Livebook versions do you use?

jonatanklosko avatar Feb 15 '24 09:02 jonatanklosko

@jyc ping :)

josevalim avatar Mar 25 '24 17:03 josevalim

Do you call Kino.start_child!/1 directly in the code cell, or from within some other process?

Directly in the code cell!

Also, for the reference, what Kino and Livebook versions do you use?

v0.12.1

I've been using Elixir for a component of my current project that I haven't touched in a month, because I've been working on other components. So unfortunately I don't have any new stacktraces to give you. But I expect to get back to the Elixir part soon!

jyc avatar Mar 25 '24 17:03 jyc