##// END OF EJS Templates
add KernelManager.load_connection_file method...
MinRK -
Show More
@@ -29,6 +29,7 b' import time'
29 import zmq
29 import zmq
30 from zmq import POLLIN, POLLOUT, POLLERR
30 from zmq import POLLIN, POLLOUT, POLLERR
31 from zmq.eventloop import ioloop
31 from zmq.eventloop import ioloop
32 from zmq.utils import jsonapi as json
32
33
33 # Local imports.
34 # Local imports.
34 from IPython.config.loader import Config
35 from IPython.config.loader import Config
@@ -36,6 +37,7 b' from IPython.utils.localinterfaces import LOCALHOST, LOCAL_IPS'
36 from IPython.utils.traitlets import (
37 from IPython.utils.traitlets import (
37 HasTraits, Any, Instance, Type, Unicode, Int, Bool
38 HasTraits, Any, Instance, Type, Unicode, Int, Bool
38 )
39 )
40 from IPython.utils.py3compat import str_to_bytes
39 from IPython.zmq.entry_point import write_connection_file
41 from IPython.zmq.entry_point import write_connection_file
40 from session import Session
42 from session import Session
41
43
@@ -788,7 +790,20 b' class KernelManager(HasTraits):'
788 # Kernel process management methods:
790 # Kernel process management methods:
789 #--------------------------------------------------------------------------
791 #--------------------------------------------------------------------------
790
792
793 def load_connection_file(self):
794 """load connection info from JSON dict in self.connection_file"""
795 with open(self.connection_file) as f:
796 cfg = json.loads(f.read())
797
798 self.ip = cfg['ip']
799 self.shell_port = cfg['shell_port']
800 self.stdin_port = cfg['stdin_port']
801 self.iopub_port = cfg['iopub_port']
802 self.hb_port = cfg['hb_port']
803 self.session.key = str_to_bytes(cfg['key'])
804
791 def write_connection_file(self):
805 def write_connection_file(self):
806 """write connection info to JSON dict in self.connection_file"""
792 if self._connection_file_written:
807 if self._connection_file_written:
793 return
808 return
794 self.connection_file,cfg = write_connection_file(self.connection_file,
809 self.connection_file,cfg = write_connection_file(self.connection_file,
General Comments 0
You need to be logged in to leave comments. Login now