##// END OF EJS Templates
Merge pull request #7668 from minrk/kernelspec-whitelist...
Merge pull request #7668 from minrk/kernelspec-whitelist Add KernelSpecManager.whitelist

File last commit:

r19234:d12d89f3
r20328:62c38e1a merge
Show More
channels.py
97 lines | 2.6 KiB | text/x-python | PythonLexer
MinRK
remove user_variables...
r16570 """A kernel client for in-process kernels."""
MinRK
update inprocess kernel to new layout...
r10298
MinRK
remove user_variables...
r16570 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
MinRK
update inprocess kernel to new layout...
r10298
Thomas Kluyver
Remove unused channel ABCs
r19234 from IPython.kernel.channelsabc import HBChannelABC
MinRK
update inprocess kernel to new layout...
r10298
from .socket import DummySocket
#-----------------------------------------------------------------------------
# Channel classes
#-----------------------------------------------------------------------------
class InProcessChannel(object):
"""Base class for in-process channels."""
proxy_methods = []
Peter Würtz
Add support for PyQt5.
r16414 def __init__(self, client=None):
MinRK
update inprocess kernel to new layout...
r10298 super(InProcessChannel, self).__init__()
self.client = client
self._is_alive = False
def is_alive(self):
return self._is_alive
def start(self):
self._is_alive = True
def stop(self):
self._is_alive = False
def call_handlers(self, msg):
""" This method is called in the main thread when a message arrives.
Subclasses should override this method to handle incoming messages.
"""
raise NotImplementedError('call_handlers must be defined in a subclass.')
Thomas Kluyver
Collapse Qt in-process channel classes together
r19222 def flush(self, timeout=1.0):
pass
MinRK
update inprocess kernel to new layout...
r10298
def call_handlers_later(self, *args, **kwds):
""" Call the message handlers later.
The default implementation just calls the handlers immediately, but this
method exists so that GUI toolkits can defer calling the handlers until
after the event loop has run, as expected by GUI frontends.
"""
self.call_handlers(*args, **kwds)
def process_events(self):
""" Process any pending GUI events.
This method will be never be called from a frontend without an event
loop (e.g., a terminal frontend).
"""
raise NotImplementedError
Thomas Kluyver
Simplify HBChannel inheritance
r19227 class InProcessHBChannel(object):
Thomas Kluyver
Improve docstring for InProcessHBChannel
r19232 """A dummy heartbeat channel interface for in-process kernels.
Normally we use the heartbeat to check that the kernel process is alive.
When the kernel is in-process, that doesn't make sense, but clients still
expect this interface.
"""
MinRK
update inprocess kernel to new layout...
r10298
time_to_dead = 3.0
Thomas Kluyver
Simplify HBChannel inheritance
r19227 def __init__(self, client=None):
super(InProcessHBChannel, self).__init__()
self.client = client
self._is_alive = False
MinRK
update inprocess kernel to new layout...
r10298 self._pause = True
Thomas Kluyver
Simplify HBChannel inheritance
r19227 def is_alive(self):
return self._is_alive
def start(self):
self._is_alive = True
def stop(self):
self._is_alive = False
MinRK
update inprocess kernel to new layout...
r10298 def pause(self):
self._pause = True
def unpause(self):
self._pause = False
def is_beating(self):
return not self._pause
HBChannelABC.register(InProcessHBChannel)