diff --git a/IPython/kernel/client.py b/IPython/kernel/client.py index 128eead..a752b85 100644 --- a/IPython/kernel/client.py +++ b/IPython/kernel/client.py @@ -56,11 +56,6 @@ class KernelClient(LoggingConfigurable, ConnectionFileMixin): def _context_default(self): return zmq.Context.instance() - # The Session to use for communication with the kernel. - session = Instance(Session) - def _session_default(self): - return Session(parent=self) - # The classes to use for the various channels shell_channel_class = Type(ShellChannel) iopub_channel_class = Type(IOPubChannel) diff --git a/IPython/kernel/connect.py b/IPython/kernel/connect.py index 80a9416..b369834 100644 --- a/IPython/kernel/connect.py +++ b/IPython/kernel/connect.py @@ -34,7 +34,7 @@ from IPython.utils.path import filefind, get_ipython_dir from IPython.utils.py3compat import (str_to_bytes, bytes_to_str, cast_bytes_py2, string_types) from IPython.utils.traitlets import ( - Bool, Integer, Unicode, CaselessStrEnum, + Bool, Integer, Unicode, CaselessStrEnum, Instance, ) @@ -433,6 +433,12 @@ class ConnectionFileMixin(Configurable): def ports(self): return [ getattr(self, name) for name in port_names ] + # The Session to use for communication with the kernel. + session = Instance('IPython.kernel.zmq.session.Session') + def _session_default(self): + from IPython.kernel.zmq.session import Session + return Session(parent=self) + #-------------------------------------------------------------------------- # Connection and ipc file management #-------------------------------------------------------------------------- @@ -506,15 +512,10 @@ class ConnectionFileMixin(Configurable): # not overridden by config or cl_args setattr(self, name, cfg[name]) - if self.session: - session = self.session - else: - session = self.config.Session - if 'key' in cfg: - session.key = str_to_bytes(cfg['key']) + self.session.key = str_to_bytes(cfg['key']) if 'signature_scheme' in cfg: - session.signature_scheme = cfg['signature_scheme'] + self.session.signature_scheme = cfg['signature_scheme'] #-------------------------------------------------------------------------- # Creating connected sockets diff --git a/IPython/kernel/manager.py b/IPython/kernel/manager.py index 798ed4f..5ff7541 100644 --- a/IPython/kernel/manager.py +++ b/IPython/kernel/manager.py @@ -46,11 +46,6 @@ class KernelManager(LoggingConfigurable, ConnectionFileMixin): def _context_default(self): return zmq.Context.instance() - # The Session to use for communication with the kernel. - session = Instance(Session) - def _session_default(self): - return Session(parent=self) - # the class to create with our `client` method client_class = DottedObjectName('IPython.kernel.blocking.BlockingKernelClient') client_factory = Type() diff --git a/IPython/kernel/zmq/kernelapp.py b/IPython/kernel/zmq/kernelapp.py index 24e265b..e53431b 100644 --- a/IPython/kernel/zmq/kernelapp.py +++ b/IPython/kernel/zmq/kernelapp.py @@ -111,7 +111,6 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, kernel = Any() poller = Any() # don't restrict this even though current pollers are all Threads heartbeat = Instance(Heartbeat) - session = Instance('IPython.kernel.zmq.session.Session') ports = Dict() # ipkernel doesn't get its own config file @@ -289,11 +288,6 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, stdin=self.stdin_port, hb=self.hb_port, control=self.control_port) - def init_session(self): - """create our session object""" - default_secure(self.config) - self.session = Session(parent=self, username=u'kernel') - def init_blackhole(self): """redirects stdout/stderr to devnull if necessary""" if self.no_stdout or self.no_stderr: @@ -363,9 +357,9 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, @catch_config_error def initialize(self, argv=None): super(IPKernelApp, self).initialize(argv) + default_secure(self.config) self.init_blackhole() self.init_connection_file() - self.init_session() self.init_poller() self.init_sockets() self.init_heartbeat()