jupyter-notebook - 通过 Jupyter 内核(Jupyter Notebook 扩展)执行代码时等待内核准备就绪
问题描述
我正在构建一个 Jupyter Notebook 扩展,一旦内核在初始化期间准备就绪,我就需要在其中执行一些代码。我正在执行我的代码如下,但我注意到有时内核在我加载我的扩展之前就准备好了,所以我的自定义事件中的代码永远不会被执行。
Jupyter.notebook.events.one('kernel_ready.Kernel', () => {
// Couldn't execute this line, because kernel was already
// ready when this event handler was attached
Jupyter.notebook.kernel.execute(someCode)
});
我可以只信任笔记本执行代码而不必担心内核准备就绪吗?我猜有某种类型的队列,所以代码最终会被执行。
Jupyter.notebook.kernel.execute(someCode)
解决方案
我是 Javascript 的初学者,但也许我可以提供一些信息,因为您的问题已部分解决并且我几天前发布的问题(Jupyter notebook custom.js not applicable when using "Restarting & Run All")。
将我的代码放入
Jupyter.notebook.events.one('kernel_ready.Kernel', () => {
在 custom.js 文件上允许我保证它在我加载脚本时被执行。
推荐阅读
- python - 在python中从pdf中提取时用空格代替俄语文本
- spfx - 如何将特定主题应用于流畅的 ui 控件?
- angular - Angular .htaccess 用于根目录和子目录
- python - 从图像中删除透明水印 - python
- elasticsearch - Grafana - 按部分消息过滤的表格数据
- python - 不同的 websocket 连接但收到的消息混淆了
- spring-boot - 在外部Tomcat中启动Spring Boot Web Application时,我问了一个关于404页的问题
- macos - 如何设置默认应用程序窗口大小
- kotlin - 将数组拆分为子数组 kotlin
- ssis - SSIS - 远程主机的 Sybase SQL Anywhere ODBC 驱动程序错误,本地数据库连接正常