Skip to content

Commit 1a3e1b8

Browse files
authored
Fix duplicate call of extension "init_cell"
There exists a possibility of calling function `run_init_cells()` twice on function `run_init_cells_asap()`. Kernel exists only as two cases: (1) Kernel is already ready, and (2) Kernel is not yet ready, and in both cases, `run_init_cells()` should be called only once. On case (1), there is no need to hook an event on `kernel_ready`, as cells are already initialized. If the event hook exists, in some specific cases, `run_init_cells()` is called twice, due to racing conditions.
1 parent b767c69 commit 1a3e1b8

File tree

1 file changed

+4
-2
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/init_cell

1 file changed

+4
-2
lines changed

src/jupyter_contrib_nbextensions/nbextensions/init_cell/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ define([
147147
// kernel is already ready
148148
run_init_cells();
149149
}
150-
// whenever a (new) kernel becomes ready, run all initialization cells
151-
events.on('kernel_ready.Kernel', run_init_cells);
150+
else {
151+
// whenever a (new) kernel becomes ready, run all initialization cells
152+
events.on('kernel_ready.Kernel', run_init_cells);
153+
}
152154
}
153155

154156
return {

0 commit comments

Comments
 (0)