Show More
@@ -37,10 +37,14 b' from zmq.eventloop import ioloop, zmqstream' | |||||
37 | from IPython.config.configurable import Configurable |
|
37 | from IPython.config.configurable import Configurable | |
38 | from IPython.utils.localinterfaces import LOCALHOST, LOCAL_IPS |
|
38 | from IPython.utils.localinterfaces import LOCALHOST, LOCAL_IPS | |
39 | from IPython.utils.traitlets import ( |
|
39 | from IPython.utils.traitlets import ( | |
40 | Any, Instance, Type, Unicode, Integer, Bool, CaselessStrEnum |
|
40 | Any, Instance, Type, Unicode, List, Integer, Bool, CaselessStrEnum | |
41 | ) |
|
41 | ) | |
42 | from IPython.utils.py3compat import str_to_bytes |
|
42 | from IPython.utils.py3compat import str_to_bytes | |
43 |
from IPython.zmq.entry_point import |
|
43 | from IPython.zmq.entry_point import ( | |
|
44 | write_connection_file, | |||
|
45 | make_kernel_cmd, | |||
|
46 | launch_kernel, | |||
|
47 | ) | |||
44 | from session import Session |
|
48 | from session import Session | |
45 | from IPython.zmq.kernelmanagerabc import ( |
|
49 | from IPython.zmq.kernelmanagerabc import ( | |
46 | ShellChannelABC, IOPubChannelABC, |
|
50 | ShellChannelABC, IOPubChannelABC, | |
@@ -677,7 +681,20 b' class KernelManager(Configurable):' | |||||
677 | return Session(config=self.config) |
|
681 | return Session(config=self.config) | |
678 |
|
682 | |||
679 | # The kernel process with which the KernelManager is communicating. |
|
683 | # The kernel process with which the KernelManager is communicating. | |
680 | kernel = Instance(Popen) |
|
684 | # generally a Popen instance | |
|
685 | kernel = Any() | |||
|
686 | ||||
|
687 | kernel_cmd = List(Unicode, config=True, | |||
|
688 | help="""The Popen Command to launch the kernel. | |||
|
689 | Override this if you have a custom | |||
|
690 | """ | |||
|
691 | ) | |||
|
692 | def _kernel_cmd_changed(self, name, old, new): | |||
|
693 | print 'kernel cmd changed', new | |||
|
694 | self.ipython_kernel = False | |||
|
695 | ||||
|
696 | ipython_kernel = Bool(True) | |||
|
697 | ||||
681 |
|
698 | |||
682 | # The addresses for the communication channels. |
|
699 | # The addresses for the communication channels. | |
683 | connection_file = Unicode('') |
|
700 | connection_file = Unicode('') | |
@@ -879,6 +896,19 b' class KernelManager(Configurable):' | |||||
879 | #-------------------------------------------------------------------------- |
|
896 | #-------------------------------------------------------------------------- | |
880 | # Kernel management |
|
897 | # Kernel management | |
881 | #-------------------------------------------------------------------------- |
|
898 | #-------------------------------------------------------------------------- | |
|
899 | ||||
|
900 | def format_kernel_cmd(self, **kw): | |||
|
901 | """format templated args (e.g. {connection_file})""" | |||
|
902 | if self.kernel_cmd: | |||
|
903 | cmd = self.kernel_cmd | |||
|
904 | else: | |||
|
905 | cmd = make_kernel_cmd( | |||
|
906 | 'from IPython.zmq.ipkernel import main; main()', | |||
|
907 | **kw | |||
|
908 | ) | |||
|
909 | ns = dict(connection_file=self.connection_file) | |||
|
910 | ns.update(self._launch_args) | |||
|
911 | return [ c.format(**ns) for c in cmd ] | |||
882 |
|
912 | |||
883 | def start_kernel(self, **kw): |
|
913 | def start_kernel(self, **kw): | |
884 | """Starts a kernel on this host in a separate process. |
|
914 | """Starts a kernel on this host in a separate process. | |
@@ -907,11 +937,13 b' class KernelManager(Configurable):' | |||||
907 | # write connection file / get default ports |
|
937 | # write connection file / get default ports | |
908 | self.write_connection_file() |
|
938 | self.write_connection_file() | |
909 |
|
939 | |||
|
940 | # save kwargs for use in restart | |||
910 | self._launch_args = kw.copy() |
|
941 | self._launch_args = kw.copy() | |
911 | launch_kernel = kw.pop('launcher', None) |
|
942 | # build the Popen cmd | |
912 | if launch_kernel is None: |
|
943 | kernel_cmd = self.format_kernel_cmd(**kw) | |
913 | from ipkernel import launch_kernel |
|
944 | print kernel_cmd | |
914 | self.kernel = launch_kernel(fname=self.connection_file, **kw) |
|
945 | # launch the kernel subprocess | |
|
946 | self.kernel = launch_kernel(kernel_cmd, ipython_kernel=self.ipython_kernel, **kw) | |||
915 |
|
947 | |||
916 | def shutdown_kernel(self, now=False, restart=False): |
|
948 | def shutdown_kernel(self, now=False, restart=False): | |
917 | """Attempts to the stop the kernel process cleanly. |
|
949 | """Attempts to the stop the kernel process cleanly. |
General Comments 0
You need to be logged in to leave comments.
Login now