<div dir="ltr"><div class="markdown-here-wrapper" id="markdown-here-wrapper-461196" style><p style="margin:1.2em 0px!important">See <a href="https://github.com/ipython/ipython/pull/4079">Pull Request #4079</a>.</p>
<p style="margin:1.2em 0px!important">On Wed, Aug 21, 2013 at 2:29 AM, Stephen Chan <<a href="mailto:sychan@lbl.gov" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=sychan@lbl.gov&cc=&bcc=&su=&body=','_blank');return false;">sychan@lbl.gov</a>> wrote:</p>


<p style="margin:1.2em 0px!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">    I've been doing some front end work on the notebook and started<br>


using the status_started.Kernel event to push authentication tokens<br>
from the browser to the ipython kernel for use in 'backend' code.<br>
<br>
   The browser code initializes before IPython.notebook.kernel is<br>
initialized, so I bound handler to status_started.Kernel to wait for<br>
the kernel to come up before calling IPython.notebook.kernel.execute()<br>
   The problem is that when I call IPython.note.kernel.execute() I am<br>
getting a DOM error that the web socket is not in readyState 1. It<br>
looks like the websocket constuctors in<br>
Kernel.prototype.start_channels() are non-blocking and return before<br>
the shell_channel is ready for a send(). This is happening on the<br>
latest Chrome (haven't tried it on FF or Safari yet).<br>
<br>
   I'm kludging around this currently by checking the readyState on<br>
the shell_channel, and if it isn't ready, using setTimeout for 500ms<br>
before calling IPython.notebook.kernel.execute()<br>
<br>
   There's an event for websocket closed, but not one for websocket<br>
opening. Would it make sense to either add another event for the<br>
websocket, or else only trigger the status_started.Kernel event once<br>
all the websockets are up? Is there another way to deal with this?<br>
<br>
   Thanks,<br>
   Steve<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=IPython-dev@scipy.org&cc=&bcc=&su=&body=','_blank');return false;">IPython-dev@scipy.org</a><br>


<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</blockquote><p></p></div><p style="margin:1.2em 0px!important"></p>
</div></div>