##// END OF EJS Templates
add Session to ConnectionFileMixin...
MinRK -
Show More
@@ -56,11 +56,6 b' class KernelClient(LoggingConfigurable, ConnectionFileMixin):'
56 def _context_default(self):
56 def _context_default(self):
57 return zmq.Context.instance()
57 return zmq.Context.instance()
58
58
59 # The Session to use for communication with the kernel.
60 session = Instance(Session)
61 def _session_default(self):
62 return Session(parent=self)
63
64 # The classes to use for the various channels
59 # The classes to use for the various channels
65 shell_channel_class = Type(ShellChannel)
60 shell_channel_class = Type(ShellChannel)
66 iopub_channel_class = Type(IOPubChannel)
61 iopub_channel_class = Type(IOPubChannel)
@@ -34,7 +34,7 b' from IPython.utils.path import filefind, get_ipython_dir'
34 from IPython.utils.py3compat import (str_to_bytes, bytes_to_str, cast_bytes_py2,
34 from IPython.utils.py3compat import (str_to_bytes, bytes_to_str, cast_bytes_py2,
35 string_types)
35 string_types)
36 from IPython.utils.traitlets import (
36 from IPython.utils.traitlets import (
37 Bool, Integer, Unicode, CaselessStrEnum,
37 Bool, Integer, Unicode, CaselessStrEnum, Instance,
38 )
38 )
39
39
40
40
@@ -433,6 +433,12 b' class ConnectionFileMixin(Configurable):'
433 def ports(self):
433 def ports(self):
434 return [ getattr(self, name) for name in port_names ]
434 return [ getattr(self, name) for name in port_names ]
435
435
436 # The Session to use for communication with the kernel.
437 session = Instance('IPython.kernel.zmq.session.Session')
438 def _session_default(self):
439 from IPython.kernel.zmq.session import Session
440 return Session(parent=self)
441
436 #--------------------------------------------------------------------------
442 #--------------------------------------------------------------------------
437 # Connection and ipc file management
443 # Connection and ipc file management
438 #--------------------------------------------------------------------------
444 #--------------------------------------------------------------------------
@@ -506,15 +512,10 b' class ConnectionFileMixin(Configurable):'
506 # not overridden by config or cl_args
512 # not overridden by config or cl_args
507 setattr(self, name, cfg[name])
513 setattr(self, name, cfg[name])
508
514
509 if self.session:
510 session = self.session
511 else:
512 session = self.config.Session
513
514 if 'key' in cfg:
515 if 'key' in cfg:
515 session.key = str_to_bytes(cfg['key'])
516 self.session.key = str_to_bytes(cfg['key'])
516 if 'signature_scheme' in cfg:
517 if 'signature_scheme' in cfg:
517 session.signature_scheme = cfg['signature_scheme']
518 self.session.signature_scheme = cfg['signature_scheme']
518
519
519 #--------------------------------------------------------------------------
520 #--------------------------------------------------------------------------
520 # Creating connected sockets
521 # Creating connected sockets
@@ -46,11 +46,6 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):'
46 def _context_default(self):
46 def _context_default(self):
47 return zmq.Context.instance()
47 return zmq.Context.instance()
48
48
49 # The Session to use for communication with the kernel.
50 session = Instance(Session)
51 def _session_default(self):
52 return Session(parent=self)
53
54 # the class to create with our `client` method
49 # the class to create with our `client` method
55 client_class = DottedObjectName('IPython.kernel.blocking.BlockingKernelClient')
50 client_class = DottedObjectName('IPython.kernel.blocking.BlockingKernelClient')
56 client_factory = Type()
51 client_factory = Type()
@@ -111,7 +111,6 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
111 kernel = Any()
111 kernel = Any()
112 poller = Any() # don't restrict this even though current pollers are all Threads
112 poller = Any() # don't restrict this even though current pollers are all Threads
113 heartbeat = Instance(Heartbeat)
113 heartbeat = Instance(Heartbeat)
114 session = Instance('IPython.kernel.zmq.session.Session')
115 ports = Dict()
114 ports = Dict()
116
115
117 # ipkernel doesn't get its own config file
116 # ipkernel doesn't get its own config file
@@ -289,11 +288,6 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
289 stdin=self.stdin_port, hb=self.hb_port,
288 stdin=self.stdin_port, hb=self.hb_port,
290 control=self.control_port)
289 control=self.control_port)
291
290
292 def init_session(self):
293 """create our session object"""
294 default_secure(self.config)
295 self.session = Session(parent=self, username=u'kernel')
296
297 def init_blackhole(self):
291 def init_blackhole(self):
298 """redirects stdout/stderr to devnull if necessary"""
292 """redirects stdout/stderr to devnull if necessary"""
299 if self.no_stdout or self.no_stderr:
293 if self.no_stdout or self.no_stderr:
@@ -363,9 +357,9 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
363 @catch_config_error
357 @catch_config_error
364 def initialize(self, argv=None):
358 def initialize(self, argv=None):
365 super(IPKernelApp, self).initialize(argv)
359 super(IPKernelApp, self).initialize(argv)
360 default_secure(self.config)
366 self.init_blackhole()
361 self.init_blackhole()
367 self.init_connection_file()
362 self.init_connection_file()
368 self.init_session()
369 self.init_poller()
363 self.init_poller()
370 self.init_sockets()
364 self.init_sockets()
371 self.init_heartbeat()
365 self.init_heartbeat()
General Comments 0
You need to be logged in to leave comments. Login now