From 54d268da8b71ceafa5b2405eb7a16f6e9dcf7146 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Thu, 22 Jun 2023 18:38:01 +0200 Subject: [PATCH 1/2] Do not clean up resources after execution Revert https://github.com/voila-dashboards/voila/pull/969 This should never have been merged. The client still needs the kernel and channels running after execution ! Co-authored-by: davidbrochart --- voila/notebook_renderer.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index 57ae2d72b..e949fc3be 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -244,8 +244,6 @@ async def _jinja_notebook_execute(self, nb, kernel_id): # (it seems to be local to our block) nb.cells = result.cells - await self._cleanup_resources() - async def _jinja_cell_generator(self, nb, kernel_id): """Generator that will execute a single notebook cell at a time""" nb, _ = ClearOutputPreprocessor().preprocess( @@ -295,12 +293,6 @@ async def _jinja_cell_generator(self, nb, kernel_id): finally: yield output_cell - await self._cleanup_resources() - - async def _cleanup_resources(self): - await ensure_async(self.executor.km.cleanup_resources()) - await ensure_async(self.executor.kc.stop_channels()) - async def load_notebook(self, path): model = await ensure_async(self.contents_manager.get(path=path)) if "content" not in model: From 096e25f235f707897731d093c9dfa3db0b6dc34c Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 26 Jun 2023 13:41:48 +0200 Subject: [PATCH 2/2] Only clean the kernel client --- voila/notebook_renderer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/voila/notebook_renderer.py b/voila/notebook_renderer.py index e949fc3be..b1a47280e 100644 --- a/voila/notebook_renderer.py +++ b/voila/notebook_renderer.py @@ -244,6 +244,8 @@ async def _jinja_notebook_execute(self, nb, kernel_id): # (it seems to be local to our block) nb.cells = result.cells + await self._cleanup_resources() + async def _jinja_cell_generator(self, nb, kernel_id): """Generator that will execute a single notebook cell at a time""" nb, _ = ClearOutputPreprocessor().preprocess( @@ -293,6 +295,11 @@ async def _jinja_cell_generator(self, nb, kernel_id): finally: yield output_cell + await self._cleanup_resources() + + async def _cleanup_resources(self): + await ensure_async(self.executor.kc.stop_channels()) + async def load_notebook(self, path): model = await ensure_async(self.contents_manager.get(path=path)) if "content" not in model: