[IPython-dev] Kernel race condition on Mac OS

Paul Butler paulgb at gmail.com
Sun Sep 15 12:29:45 EDT 2013


I'm developing with the kernel APIs and I've encountered a race condition.
It seems to be a Mac-specific thing; I haven't been able to reproduce it on
Ubuntu or CentOS.

The following code demonstrates the problem. It's also available as a
The call to iopub.get_msg will (usually) fail unless sleep(1) is

from IPython.kernel import KernelManager
from time import sleep

def racecondition():
    km = KernelManager()

    kc = km.client()

    iopub = kc.iopub_channel
    shell = kc.shell_channel


    shell.execute('print "hello world"')
    print shell.get_msg(timeout=1)
    print iopub.get_msg(timeout=1)

if __name__ == '__main__':

By experimenting with where the sleep(1) call can go, it seems that
the kernel subprocess takes a few milliseconds to be ready to accept

Is there any call to check if the kernel is ready?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130915/cfcaee8c/attachment.html>

More information about the IPython-dev mailing list