[IPython-dev] Simple Kernel Example

Doug Blank doug.blank at gmail.com
Thu Jan 23 08:47:00 EST 2014


On Tue, Jan 21, 2014 at 12:41 PM, Doug Blank <doug.blank at gmail.com> wrote:
> On Mon, Jan 20, 2014 at 12:01 PM, Matthias BUSSONNIER
> <bussonniermatthias at gmail.com> wrote:
>
> [snip]
>
>>>> 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
>
> Thanks for the feedback... your comments help me realize that I was
> looking at the wrong side of the socket code as examples. I've made
> more progress, but still looking for help on the code:
>
> https://github.com/dsblank/simple_kernel

Thanks to hints given, I now have a working, simple_kernel.py. No one
from IPython has looked at that yet, so I don't know if there are
issues, let alone if this is best practices. But it does work.

Questions still:

> Some specific questions:
>
> 1) Does the kernel need to handle the "ident" bytes on the front end
> of messages before the delimiter? I see a couple of options: a) ignore
> them, b) pass them back with responses, c) do something with them?
> What do they represent?

It looks like the ident bytes on the front are a type of routing info
in the form of "username.engine_id.message_id". I have ignored them so
far. Am I losing functionality if I don't send them?

> 2) Could someone provide an example of a execute_request/execute_reply
> exchange of messages. I'm having trouble getting the conversation to
> work. Specifically, looking for how execute_reply, pyout, pyin
> message_types are related, and which sockets they are sent on.

I now have that working. Errors that I had: using socket.connect() vs
socket.bind(), not flushing the stream when sending, using wrong
zmq.MODE (DEALER, PUB, SUB, etc) when creating the socket, missing
JSON fields, and using the wrong socket (ie, "channel"). To solve
these issues I put some print statements in IPython/kernel/channels.py
when sending and recving and mirrored these details.

The documentation is good, but I find that examples of the messages
being exchanged to be useful to make it concrete. Also, it seems that
some details are not specified in the docs.

I'll continue to make simple_kernel better, if I receive feedback or
add to it. Now, I'm ready to implement my real goal in C#...

> -Doug



More information about the IPython-dev mailing list