Here is another jupyter prototype. It creates sockets and ZMQ channels. I
haven't actually used these, but the process has been instructive. Here is
the @button node:
from jupyter_client import client
from jupyter_client.blocking.channels import ZMQSocketChannel
def put(tag, val):
pad = max(0, 20-len(tag)) * ' '
print('%s%s: %s' % (pad, tag, val))
def make_channel(channel_name):
print('-'*20)
put('channel_name', channel_name)
url = cl._make_url(channel_name)
put('url', url)
cl.log.debug("connecting %s channel to %s" % (channel_name, url))
socket = cl.connect_shell(identity=cl.session.bsession)
put('socket', socket)
channel = ZMQSocketChannel(socket, cl.session)
###### New code: don't use the various _x_channel_class values.
put('channel', channel)
return channel
put('g.isPython3', g.isPython3)
cl = client.KernelClient()
put('shell_channel_class', cl.shell_channel_class)
put('session', cl.session)
cl._shell_channel = make_channel('shell')
cl._iopub_channel = make_channel('iopub')
cl._stdin_channel = make_channel('stdin')
cl._hb_channel = make_channel('hb')
cl.allow_stdin = True
print('Done')
Here is the output:
g.isPython3: True
shell_channel_class: <class 'jupyter_client.channelsabc.ChannelABC'>
session: <jupyter_client.session.Session object at 0x0611CDD0>
--------------------
channel_name: shell
url: tcp://127.0.0.1:0
socket: <zmq.sugar.socket.Socket object at 0x0A65C260>
channel: <jupyter_client.blocking.channels.ZMQSocketChannel
object at 0x06246C70>
--------------------
channel_name: iopub
url: tcp://127.0.0.1:0
socket: <zmq.sugar.socket.Socket object at 0x0A65C030>
channel: <jupyter_client.blocking.channels.ZMQSocketChannel
object at 0x06246910>
--------------------
channel_name: stdin
url: tcp://127.0.0.1:0
socket: <zmq.sugar.socket.Socket object at 0x0A65C500>
channel: <jupyter_client.blocking.channels.ZMQSocketChannel
object at 0x062465B0>
--------------------
channel_name: hb
url: tcp://127.0.0.1:0
socket: <zmq.sugar.socket.Socket object at 0x0A65C180>
channel: <jupyter_client.blocking.channels.ZMQSocketChannel
object at 0x06246AF0>
*Discussion*
I would have liked to create these channels using
KernelClient.start_channels, but I don't see how to make the KernelClient
class use a ZMQSocketChannel by default.
For example, cl.shell_channel_class = Type(ZMQSocketChannel) results in a
traitlets type error!
As a workaround, the script defines make_channel helper instead of calling
KernelClient.start_channels.
I'm not sure whether using a blocking channel is what is wanted...
And I'm not sure how to use the four created channels. Hehe.
Still, I think this code is a step forward. The code reveals class
structure and traitlets constraints.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.