You’re doing everything right, there’s just some zmq magic that’s getting in the way of things behaving clearly. The short answer to your question is that it’s never to early to send a shell request. zmq is ‘connectionless’ which is the zmq way of saying that you can send messages even when the other end hasn’t shown up yet. It will handle delivering the message when the kernel shows up. This is why POLLOUT is true immediately. What you are likely running into is a failure to propagate subscriptions on the PUB/SUB channel. If a PUB socket sends a message and it has no registered subscribers, it will discard those messages immediately. And propagating those subscriptions takes a finite amount of time.
So the common failure is:
The way we deal with this is explicitly waiting for IOPub messages to be delivered before sending requests. This is implemented in BlockingKernelClient.wait_for_ready. But the logic is:
if reply came and idle didn’t, IOPub subscriptions may not have propagated, run again. This typically takes ~milliseconds, so the second try will always work. Here’s a script that starts a kernel and connects a client to it and runs a bit of code.
-Min
--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/20e29f70-cb0f-4c11-84a6-a94866b72098%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.