@ -62,6 +62,7 @@ define([
this . save _widget = options . save _widget ;
this . tooltip = new tooltip . Tooltip ( this . events ) ;
this . ws _url = options . ws _url ;
this . _session _starting = false ;
// default_kernel_name is a temporary measure while we implement proper
// kernel selection and delayed start. Do not rely on it.
this . default _kernel _name = 'python' ;
@ -1525,9 +1526,38 @@ define([
* @ method start _session
* /
Notebook . prototype . start _session = function ( kernel _name ) {
var that = this ;
if ( kernel _name === undefined ) {
kernel _name = this . default _kernel _name ;
}
if ( this . _session _starting ) {
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 ( {
base _url : this . base _url ,
ws _url : this . ws _url ,
@ -1539,7 +1569,10 @@ define([
kernel _name : kernel _name ,
notebook : this } ) ;
this . session . start ( $ . proxy ( this . _session _started , this ) ) ;
this . session . start (
$ . proxy ( this . _session _started , this ) ,
$ . proxy ( this . _session _start _failed , this )
) ;
} ;
@ -1548,7 +1581,8 @@ define([
* comm manager to the widget manager
*
* /
Notebook . prototype . _session _started = function ( ) {
Notebook . prototype . _session _started = function ( ) {
this . _session _starting = false ;
this . kernel = this . session . kernel ;
var ncells = this . ncells ( ) ;
for ( var i = 0 ; i < ncells ; i ++ ) {
@ -1558,7 +1592,11 @@ define([
}
}
} ;
Notebook . prototype . _session _start _failed = function ( jqxhr , status , error ) {
this . _session _starting = false ;
utils . log _ajax _error ( jqxhr , status , error ) ;
} ;
/ * *
* Prompt the user to restart the IPython kernel .
*