python - iPython notebook - 配置为在关闭选项卡时关闭内核

标签 python ipython-notebook

官方网站it is said :

When a notebook is opened, its “computational engine” (called the kernel) is automatically started. Closing the notebook browser tab, will not shut down the kernel, instead the kernel will keep running until is explicitly shut down."

是否可以配置 iPython 服务器,以便内核与关联的选项卡一起被杀死?

最佳答案

经过一些研究和多次尝试,解决方案非常简单。在文件 profile/static/custom/custom.js 末尾添加以下代码:

$( window ).unload(function() {
  IPython.notebook.kernel.kill();
});

非常适合我! (在 Chrome 上试过)

关于python - iPython notebook - 配置为在关闭选项卡时关闭内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32824542/

相关文章:

python - 根据传递的变量更改 HTML 表格中的颜色

python - Jinja2 宏导入 "with context"和全局变量 : {% from file. html import macro_name with context %}

ipython-notebook - 新的 ipython 笔记本模板

python - 如何在 IPython/Jupyter 笔记本中自动加载配置文件?

python - 如何在 IPython notebook 中显示包函数的源代码

Python程序找到连续数值的总和等于数字n?

c# - 将图像 Python 代码转换为 C#

python - 如何在 Pandas 中添加字符串数字

ipython-notebook - ipython 笔记本 : custom cells and execute hook

ipython-notebook - 非 Python 语言语法高亮?