Use Session.restart in Notebook.start_session

Jessica B. Hamrick 11 years ago
parent d5a4dec6c3
commit fa718fc8d2

@ -1558,45 +1558,25 @@ define([
throw new session.SessionAlreadyStarting();
}
this._session_starting = true;
if (this.session !== null) {
var s = this.session;
this.session = null;
// need to start the new session in a callback after delete,
// because javascript does not guarantee the ordering of AJAX requests (?!)
s.delete(function () {
// on successful delete, start new session
that._session_starting = false;
that.start_session(kernel_name);
}, function (jqXHR, status, error) {
// log the failed delete, but still create a new session
// 404 just means it was already deleted by someone else,
// but other errors are possible.
utils.log_ajax_error(jqXHR, status, error);
that._session_starting = false;
that.start_session(kernel_name);
}
);
return;
}
this.session = new session.Session({
var options = {
base_url: this.base_url,
ws_url: this.ws_url,
notebook_path: this.notebook_path,
notebook_name: this.notebook_name,
// For now, create all sessions with the 'python' kernel, which is the
// default. Later, the user will be able to select kernels. This is
// overridden if KernelManager.kernel_cmd is specified for the server.
kernel_name: kernel_name,
notebook: this});
notebook: this
};
this.session.start(
$.proxy(this._session_started, this),
$.proxy(this._session_start_failed, this)
);
var success = $.proxy(this._session_started, this);
var failure = $.proxy(this._session_start_failed, this);
if (this.session !== null) {
this.session.restart(options, success, failure);
} else {
this.session = new session.Session(options);
this.session.start(success, failure);
}
};

Loading…
Cancel
Save