[IPython-dev] blocking kernel client is not ready after call to start_channels, solution provided
Christoph Szeppek
chris at myrage.com
Mon Jun 2 08:46:42 EDT 2014
Hi IPython Developers!
I'm pretty new to IPython and tried to send a single command to a
newly started kernel. I use the KernelManager.start_kernel() method to
start the kernel, then call KernelManager.client() to get a blocking
client, then called client.execute() and tried to fetch a
execute_reply and maybe a msg_type: stream message on the iopub and
shell channels by calling their get_msgs() methods.
I repeated this step several times and occasionally, there was no data
received on the iopub channel at all. I tried to wait for
client.channels_running to be True but this indicates weather the
channel's thread's run() method has been called, not weather it has
completed, so the handler for incoming messages on that channel may
not have been set up at that time.
It turned out that one has to wait for shell and iopub channel's
ioloop._running to be True before receiving data on that channel.
So I added the following method to the client:
def channels_ready(self):
return (self.shell_channel.ioloop._running and
self.iopub_channel.ioloop._running)
for which I now wait to be true before calling the client's execute method.
Best Regards,
Christoph
More information about the IPython-dev
mailing list