@@ -421,7 +421,10 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
421421
422422 protected  abstract  closeBecauseOfFailure ( exc : Error ) : Promise < void > ; 
423423
424-  protected  clearResult ( id : string ) : void   { 
424+  protected  async  clearResult ( id : string ) : Promise < void >  { 
425+  // This will get called during an execution, so we need to have 
426+  // a notebook ready. 
427+  await  this . ensureServerActive ( ) ; 
425428 if  ( this . notebook )  { 
426429 this . notebook . clear ( id ) ; 
427430 } 
@@ -460,18 +463,8 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
460463 } ; 
461464
462465 try  { 
463- 
464466 // Make sure we're loaded first. 
465-  try  { 
466-  traceInfo ( 'Waiting for jupyter server and web panel ...' ) ; 
467-  await  this . startServer ( ) ; 
468-  }  catch  ( exc )  { 
469-  // We should dispose ourselves if the load fails. Othewise the user 
470-  // updates their install and we just fail again because the load promise is the same. 
471-  await  this . closeBecauseOfFailure ( exc ) ; 
472- 
473-  throw  exc ; 
474-  } 
467+  await  this . ensureServerActive ( ) ; 
475468
476469 // Then show our webpanel 
477470 await  this . show ( ) ; 
@@ -661,6 +654,53 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
661654 return  result ; 
662655 } 
663656
657+  protected  async  addSysInfo ( reason : SysInfoReason ) : Promise < void >  { 
658+  if  ( ! this . addSysInfoPromise  ||  reason  !==  SysInfoReason . Start )  { 
659+  traceInfo ( `Adding sys info for ${ this . id }   ${ reason }  ` ) ; 
660+  const  deferred  =  createDeferred < boolean > ( ) ; 
661+  this . addSysInfoPromise  =  deferred ; 
662+ 
663+  // Generate a new sys info cell and send it to the web panel. 
664+  const  sysInfo  =  await  this . generateSysInfoCell ( reason ) ; 
665+  if  ( sysInfo )  { 
666+  this . sendCellsToWebView ( [ sysInfo ] ) ; 
667+  } 
668+ 
669+  // For anything but start, tell the other sides of a live share session 
670+  if  ( reason  !==  SysInfoReason . Start  &&  sysInfo )  { 
671+  this . shareMessage ( InteractiveWindowMessages . AddedSysInfo ,  {  type : reason ,  sysInfoCell : sysInfo ,  id : this . id  } ) ; 
672+  } 
673+ 
674+  // For a restart, tell our window to reset 
675+  if  ( reason  ===  SysInfoReason . Restart  ||  reason  ===  SysInfoReason . New )  { 
676+  this . postMessage ( InteractiveWindowMessages . RestartKernel ) . ignoreErrors ( ) ; 
677+  if  ( this . notebook )  { 
678+  this . jupyterDebugger . onRestart ( this . notebook ) ; 
679+  } 
680+  } 
681+ 
682+  traceInfo ( `Sys info for ${ this . id }   ${ reason }   complete` ) ; 
683+  deferred . resolve ( true ) ; 
684+  }  else  if  ( this . addSysInfoPromise )  { 
685+  traceInfo ( `Wait for sys info for ${ this . id }   ${ reason }  ` ) ; 
686+  await  this . addSysInfoPromise . promise ; 
687+  } 
688+  } 
689+ 
690+  private  async  ensureServerActive ( ) : Promise < void >  { 
691+  // Make sure we're loaded first. 
692+  try  { 
693+  traceInfo ( 'Waiting for jupyter server and web panel ...' ) ; 
694+  await  this . startServer ( ) ; 
695+  }  catch  ( exc )  { 
696+  // We should dispose ourselves if the load fails. Othewise the user 
697+  // updates their install and we just fail again because the load promise is the same. 
698+  await  this . closeBecauseOfFailure ( exc ) ; 
699+ 
700+  throw  exc ; 
701+  } 
702+  } 
703+ 
664704 private  async  startServerImpl ( ) : Promise < void >  { 
665705 // Status depends upon if we're about to connect to existing server or not. 
666706 const  status  =  ( await  this . jupyterExecution . getServer ( await  this . getNotebookOptions ( ) ) )  ?
@@ -1077,39 +1117,6 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp
10771117 return  `${ localize . DataScience . sysInfoURILabel ( ) } ${ urlString }  ` ; 
10781118 } 
10791119
1080-  private  addSysInfo  =  async  ( reason : SysInfoReason ) : Promise < void >  =>  { 
1081-  if  ( ! this . addSysInfoPromise  ||  reason  !==  SysInfoReason . Start )  { 
1082-  traceInfo ( `Adding sys info for ${ this . id }   ${ reason }  ` ) ; 
1083-  const  deferred  =  createDeferred < boolean > ( ) ; 
1084-  this . addSysInfoPromise  =  deferred ; 
1085- 
1086-  // Generate a new sys info cell and send it to the web panel. 
1087-  const  sysInfo  =  await  this . generateSysInfoCell ( reason ) ; 
1088-  if  ( sysInfo )  { 
1089-  this . sendCellsToWebView ( [ sysInfo ] ) ; 
1090-  } 
1091- 
1092-  // For anything but start, tell the other sides of a live share session 
1093-  if  ( reason  !==  SysInfoReason . Start  &&  sysInfo )  { 
1094-  this . shareMessage ( InteractiveWindowMessages . AddedSysInfo ,  {  type : reason ,  sysInfoCell : sysInfo ,  id : this . id  } ) ; 
1095-  } 
1096- 
1097-  // For a restart, tell our window to reset 
1098-  if  ( reason  ===  SysInfoReason . Restart  ||  reason  ===  SysInfoReason . New )  { 
1099-  this . postMessage ( InteractiveWindowMessages . RestartKernel ) . ignoreErrors ( ) ; 
1100-  if  ( this . notebook )  { 
1101-  this . jupyterDebugger . onRestart ( this . notebook ) ; 
1102-  } 
1103-  } 
1104- 
1105-  traceInfo ( `Sys info for ${ this . id }   ${ reason }   complete` ) ; 
1106-  deferred . resolve ( true ) ; 
1107-  }  else  if  ( this . addSysInfoPromise )  { 
1108-  traceInfo ( `Wait for sys info for ${ this . id }   ${ reason }  ` ) ; 
1109-  await  this . addSysInfoPromise . promise ; 
1110-  } 
1111-  } 
1112- 
11131120 private  async  checkUsable ( ) : Promise < boolean >  { 
11141121 let  activeInterpreter : PythonInterpreter  |  undefined ; 
11151122 try  { 
0 commit comments