Skip to content

Commit

Permalink
Use getter for kernel instance
Browse files Browse the repository at this point in the history
Helps with case where kernel is restarted and a new kernel
instance used.

Ref jupyter#141
Ref jupyter#196

(c) Copyright IBM Corp. 2016
  • Loading branch information
jhpedemonte committed Mar 9, 2016
1 parent 322e4c8 commit d46a2e6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nb-extension/js/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,16 @@ define([
Urth.suppressErrors = config.suppressErrors;

Urth.events = config.events;
Urth.kernel = IPython.notebook.kernel;

// specify a getter for the kernel instance, since it can be restarted and a new kernel
// instantiated
Object.defineProperty(Urth, 'kernel', {
get: function() {
// TODO What is the correct way of handling this outside of the notebook? What
// should we do when using jupyter-js-services and kernel is restarted?
return IPython.notebook.kernel;
}
});

isServerExtensionAvailable(baseURL + COMPONENTS_DIR, function(isAvailable){
console.log('Server extension is ' + (isAvailable ? '' : 'NOT ') + 'available!');
Expand Down

0 comments on commit d46a2e6

Please sign in to comment.