##// END OF EJS Templates
Stub out kernel methods to allow overriding a subset of them.
Thomas Kluyver -
Show More
@@ -68,6 +68,10 b' class Kernel(KernelBase):'
68 68 def banner(self):
69 69 return self.shell.banner
70 70
71 def start(self):
72 self.shell.exit_now = False
73 super(Kernel, self).start()
74
71 75 def set_parent(self, ident, parent):
72 76 """Overridden from parent to tell the display hook and output streams
73 77 about the parent message.
@@ -225,7 +225,6 b' class KernelBase(Configurable):'
225 225
226 226 def start(self):
227 227 """register dispatchers for streams"""
228 self.shell.exit_now = False
229 228 if self.control_stream:
230 229 self.control_stream.on_recv(self.dispatch_control, copy=False)
231 230
@@ -374,6 +373,12 b' class KernelBase(Configurable):'
374 373
375 374 self._publish_status(u'idle', parent)
376 375
376 def do_execute(self, code, silent, store_history=True,
377 user_experssions=None, allow_stdin=False):
378 """Execute user code. Must be overridden by subclasses.
379 """
380 raise NotImplementedError
381
377 382 def complete_request(self, stream, ident, parent):
378 383 content = parent['content']
379 384 code = content['code']
@@ -385,6 +390,15 b' class KernelBase(Configurable):'
385 390 matches, parent, ident)
386 391 self.log.debug("%s", completion_msg)
387 392
393 def do_complete(self, code, cursor_pos):
394 """Override in subclasses to find completions.
395 """
396 return {'matches' : [],
397 'cursor_end' : cursor_pos,
398 'cursor_start' : cursor_pos,
399 'metadata' : {},
400 'status' : 'ok'}
401
388 402 def inspect_request(self, stream, ident, parent):
389 403 content = parent['content']
390 404
@@ -396,6 +410,11 b' class KernelBase(Configurable):'
396 410 reply_content, parent, ident)
397 411 self.log.debug("%s", msg)
398 412
413 def do_inspect(self, code, cursor_pos, detail_level=0):
414 """Override in subclasses to allow introspection.
415 """
416 return {'status': 'ok', 'data':{}, 'metadata':{}, 'found':False}
417
399 418 def history_request(self, stream, ident, parent):
400 419 # We need to pull these out, as passing **kwargs doesn't work with
401 420 # unicode keys before Python 2.6.5.
@@ -416,6 +435,12 b' class KernelBase(Configurable):'
416 435 reply_content, parent, ident)
417 436 self.log.debug("%s", msg)
418 437
438 def do_history(self, hist_access_type, output, raw, session=None, start=None,
439 stop=None, n=None, pattern=None, unique=False):
440 """Override in subclasses to access history.
441 """
442 return {'history': []}
443
419 444 def connect_request(self, stream, ident, parent):
420 445 if self._recorded_ports is not None:
421 446 content = self._recorded_ports.copy()
@@ -454,6 +479,12 b' class KernelBase(Configurable):'
454 479 loop = ioloop.IOLoop.instance()
455 480 loop.add_timeout(time.time()+0.1, loop.stop)
456 481
482 def do_shutdown(self, restart):
483 """Override in subclasses to do things when the frontend shuts down the
484 kernel.
485 """
486 return {'status': 'ok', 'restart': restart}
487
457 488 #---------------------------------------------------------------------------
458 489 # Engine methods
459 490 #---------------------------------------------------------------------------
@@ -488,6 +519,11 b' class KernelBase(Configurable):'
488 519
489 520 self._publish_status(u'idle', parent)
490 521
522 def do_apply(self, content, bufs, msg_id, reply_metadata):
523 """Override in subclasses to support the IPython parallel framework.
524 """
525 raise NotImplementedError
526
491 527 #---------------------------------------------------------------------------
492 528 # Control messages
493 529 #---------------------------------------------------------------------------
@@ -513,6 +549,13 b' class KernelBase(Configurable):'
513 549 self.session.send(stream, 'clear_reply', ident=idents, parent=parent,
514 550 content = content)
515 551
552 def do_clear(self):
553 """Override in subclasses to clear the namespace
554
555 This is only required for IPython.parallel.
556 """
557 raise NotImplementedError
558
516 559 #---------------------------------------------------------------------------
517 560 # Protected interface
518 561 #---------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now