[IPython-dev] Simple Kernel Example

Matthias BUSSONNIER bussonniermatthias at gmail.com
Mon Jan 20 12:01:23 EST 2014


Le 20 janv. 2014 à 17:08, Doug Blank a écrit :

> Thanks for the help! Of course, I'm partly giving you feedback to help
> the next people that come along attempting to make a new kernel. Some
> comments below:
> 
>> 
> 
> I guess that when I originally ran the "ipython profile create
> simple_kernel" that I had been using IPython version 0.13 which comes
> with Ubuntu 13.10. It only created the ipython_config.py. Now that I
> have upgraded to 1.1, I see that there are many kernel-related items
> in this new ipython_notebook_config.py. Great!

Yes, updates can be tricky with config files too, we are thinking about that. 
> 
> Some of the other kernels for other languages are written to use a
> specific version of ipython. For example, igo apparent is written for
> IPython 1.2.  This has made understanding the various examples more
> difficult.

We try to change the protocol as little as possible, but some feedback from 
non-python kernel had us add some things, still the basic common denominator
 should not have changed lot since 0.13.

> 
> One related point of confusion I have: from this hint that you have
> given, it appears that you need to have different kernels for
> different frontends; is that true?

No, once you have written a kernel it will work for all frontend.
Assuming the kernel is full-featured, otherwise some feature might make the 
frontend crash.

> I was assuming that the frontend
> and the kernel could negotiate over what sockets communications were
> required/optional/ignored.

We try to do our best, but as Python kernel is the most used we often forget corner case, 
if you come to such corner case, please tell us.

> For example, it took me three days to
> realize that the heartbeat interface is not used from the notebook
> interface.

the notebook one is tricky, as the notebook is not the **real** frontend. 
the real frontend is the tornado server that act as a ZMQ <-> Websocket bridge, 
and IIRC the server is listening for heartbeat and will auto restart kernel is heartbeat fails
(up to 5 times) it just "informs" the browser that kernel has been restarted. 

> Is there a way that simple_kernel.py can determine that?

In theory no, in practice you can peak at some value or try to publish some info, but that is not reliable. 
in particular you can have emacs that talk to the browser through web socket instead of browser. 

> Or do I need different config settings for each frontend/kernel
> combination?

You do need (for the time being) to tell each frontend how to start a kernel separately, 
but this does not mean that you should change the configuration of your kernel. 

IIRC though, KernelManager is the base class from which all frontend inherit, so 
if you set KernelManager.kernel_cmd on ipython_config.py it should apply at once to all frontend. 

This part is tricky because KernelManager is instantiated only in IPython sub-app, so it will not appear in
ipython --help-all or ipython_config.py but will on each of the individual configuration file or help. 

> 
>> Haven't looked at your simple_kernel.py yet.
> 
> I have cleaned up the code some, but as far as I can tell, nothing is working.

I'm not sure sockets like passing between threads. 
And I think kernel side should use bind instead of connect because there is an asymetrie in req/res and pub/sub


-- 
M

> 
> -Doug
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev




More information about the IPython-dev mailing list