From 74f89725056a477bf528f46ea8019301636ddf72 Mon Sep 17 00:00:00 2001 From: MinRK Date: Mon, 18 Mar 2013 21:55:42 -0700 Subject: [PATCH] specify socket identity from kernel.js required for stdin routing --- IPython/frontend/html/notebook/handlers.py | 8 +++++++- IPython/frontend/html/notebook/static/js/kernel.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 31a56a4bf..83796911b 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -506,6 +506,12 @@ class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler): # Cookie constructor doesn't accept unicode strings # under Python 2.x for some reason msg = msg.encode('utf8', 'replace') + try: + bsession, msg = msg.split(':', 1) + self.session.session = bsession.decode('ascii') + except Exception: + logging.error("No bsession!", exc_info=True) + pass try: self.request._cookies = Cookie.SimpleCookie(msg) except: @@ -528,7 +534,7 @@ class ZMQChannelHandler(AuthenticatedZMQStreamHandler): def create_stream(self): km = self.kernel_manager meth = getattr(km, 'connect_%s' % self.channel) - self.zmq_stream = meth(self.kernel_id) + self.zmq_stream = meth(self.kernel_id, identity=self.session.bsession) def initialize(self, *args, **kwargs): self.zmq_stream = None diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index ee304db4a..78741c7f6 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -129,7 +129,7 @@ var IPython = (function (IPython) { this.shell_channel = new this.WebSocket(ws_url + "/shell"); this.iopub_channel = new this.WebSocket(ws_url + "/iopub"); send_cookie = function(){ - this.send(document.cookie); + this.send(that.session_id + ':' + document.cookie); }; var already_called_onclose = false; // only alert once var ws_closed_early = function(evt){