Skip to content

Commit

Permalink
specify socket identity from kernel.js
Browse files Browse the repository at this point in the history
required for stdin routing
  • Loading branch information
minrk committed Apr 25, 2013
1 parent 8fae131 commit 24dcb6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion IPython/frontend/html/notebook/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ def _inject_cookie_message(self, msg):
# 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:
Expand All @@ -528,7 +534,7 @@ def max_msg_size(self):
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
Expand Down
2 changes: 1 addition & 1 deletion IPython/frontend/html/notebook/static/js/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit 24dcb6b

Please sign in to comment.