IPython Notebook - Detect if Kernel is Busy/Idle in Javascript

我的梦境 提交于 2019-12-10 13:27:42

问题


I'm currently trying to get interactive plots working with IPython notebook. One of the issues I'm having is the fact that when executing Python code through the IPython.notebook.kernel.execute method in javascript I have no way of knowing when that piece of code has finished executing. Is there an easy way of detecting whether the kernel is busy/idle so that I can tell Javascript to idle until it's completed?


回答1:


The Kernel status is probably what you are looking for:

http://ipython.org/ipython-doc/dev/development/messaging.html#kernel-status

You can find some additional inspiration in the kernel.js of the IPython notebook (just search for "busy"):

https://github.com/ipython/ipython/blob/master/IPython/frontend/html/notebook/static/js/kernel.js




回答2:


I know this is a really old question, but just in case anyone is looking...

    require(['base/js/namespace', 'base/js/events'], function (IPython, events) {
        events.on('kernel_idle.Kernel', yourFunction);
    });


来源:https://stackoverflow.com/questions/13461211/ipython-notebook-detect-if-kernel-is-busy-idle-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!