specify socket identity from kernel.js

required for stdin routing
This commit is contained in:
MinRK 2013-03-18 21:55:42 -07:00
parent 510897f0aa
commit 74f8972505
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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){