##// END OF EJS Templates
Use Session.restart in Notebook.start_session
Jessica B. Hamrick -
Show More
@@ -1558,45 +1558,25 b' define(['
1558 throw new session.SessionAlreadyStarting();
1558 throw new session.SessionAlreadyStarting();
1559 }
1559 }
1560 this._session_starting = true;
1560 this._session_starting = true;
1561
1561
1562 if (this.session !== null) {
1562 var options = {
1563 var s = this.session;
1564 this.session = null;
1565 // need to start the new session in a callback after delete,
1566 // because javascript does not guarantee the ordering of AJAX requests (?!)
1567 s.delete(function () {
1568 // on successful delete, start new session
1569 that._session_starting = false;
1570 that.start_session(kernel_name);
1571 }, function (jqXHR, status, error) {
1572 // log the failed delete, but still create a new session
1573 // 404 just means it was already deleted by someone else,
1574 // but other errors are possible.
1575 utils.log_ajax_error(jqXHR, status, error);
1576 that._session_starting = false;
1577 that.start_session(kernel_name);
1578 }
1579 );
1580 return;
1581 }
1582
1583
1584
1585 this.session = new session.Session({
1586 base_url: this.base_url,
1563 base_url: this.base_url,
1587 ws_url: this.ws_url,
1564 ws_url: this.ws_url,
1588 notebook_path: this.notebook_path,
1565 notebook_path: this.notebook_path,
1589 notebook_name: this.notebook_name,
1566 notebook_name: this.notebook_name,
1590 // For now, create all sessions with the 'python' kernel, which is the
1591 // default. Later, the user will be able to select kernels. This is
1592 // overridden if KernelManager.kernel_cmd is specified for the server.
1593 kernel_name: kernel_name,
1567 kernel_name: kernel_name,
1594 notebook: this});
1568 notebook: this
1569 };
1595
1570
1596 this.session.start(
1571 var success = $.proxy(this._session_started, this);
1597 $.proxy(this._session_started, this),
1572 var failure = $.proxy(this._session_start_failed, this);
1598 $.proxy(this._session_start_failed, this)
1573
1599 );
1574 if (this.session !== null) {
1575 this.session.restart(options, success, failure);
1576 } else {
1577 this.session = new session.Session(options);
1578 this.session.start(success, failure);
1579 }
1600 };
1580 };
1601
1581
1602
1582
General Comments 0
You need to be logged in to leave comments. Login now