IPython Notebook - 在Javascript中检测内核是否忙/闲 [英] IPython Notebook - Detect if Kernel is Busy/Idle in Javascript
问题描述
我目前正在尝试使用IPython笔记本进行交互式绘图。我遇到的一个问题是,当在javascript中通过IPython.notebook.kernel.execute方法执行Python代码时,我无法知道该段代码何时完成执行。是否有一种简单的方法可以检测内核是忙还是空闲,这样我就可以告诉Javascript闲置直到它完成?
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?
推荐答案
内核状态可能就是你要找的东西:
The Kernel status is probably what you are looking for:
http://ipython.org/ipython-doc/dev/development/messaging.html#kernel-status
你可以在IPython笔记本的kernel.js中找到一些额外的灵感(只搜索忙):
You can find some additional inspiration in the kernel.js of the IPython notebook (just search for "busy"):
这篇关于IPython Notebook - 在Javascript中检测内核是否忙/闲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!