livebook-dev/kino

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

Closed this issue · 7 comments

jyc commented

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.

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
jyc commented

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!

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?

@jyc ping :)

jyc commented

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!

Should we close this one?

Let's close and reopen if we have more information. :) Thank you!