Skip to content

Commit 797e921

Browse files
authored
Merge pull request #969 from martinRenou/cleanup_executor_resources
Cleanup executor resources after execution
2 parents 1737b86 + 3f00328 commit 797e921

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

voila/handler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ async def _jinja_notebook_execute(self, nb, kernel_id):
200200
# see the updated variable (it seems to be local to our block)
201201
nb.cells = result.cells
202202

203+
await self._cleanup_resources()
204+
203205
async def _jinja_cell_generator(self, nb, kernel_id):
204206
"""Generator that will execute a single notebook cell at a time"""
205207
nb, resources = ClearOutputPreprocessor().preprocess(nb, {'metadata': {'path': self.cwd}})
@@ -250,6 +252,12 @@ async def _jinja_cell_generator(self, nb, kernel_id):
250252
finally:
251253
yield output_cell
252254

255+
await self._cleanup_resources()
256+
257+
async def _cleanup_resources(self):
258+
await ensure_async(self.executor.km.cleanup_resources())
259+
await ensure_async(self.executor.kc.stop_channels())
260+
253261
async def load_notebook(self, path):
254262
model = await ensure_async(self.contents_manager.get(path=path))
255263
if 'content' not in model:

0 commit comments

Comments
 (0)