Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to bind to a ruby kernel #2643

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions IPython/zmq/subprocesskernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#-----------------------------------------------------------------------------
# Copyright (C) 2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------


from subprocess import Popen
from os.path import expanduser

from IPython.zmq.kernelmanager import KernelManager
from IPython.utils.traitlets import List
from IPython.config.configurable import Configurable


class SubprocessKernelManager(KernelManager, Configurable):

kernel_launch_program = List(
[],
config=True,
help="""the command to launch a foreign language kernel, use '{connection_file_name}' to have
the full path of the connection file.
"""
)

def start_kernel(self, **kw):
kw['launcher'] = self.launch_subprocess_kernel
return KernelManager.start_kernel(self, **kw)

def launch_subprocess_kernel(self, fname='cf.json', **kw):
if not self.kernel_launch_program :
raise ValueError("""kernel_launch program should be defined
in config with the following form :

c.SubprocessKernelManager.kernel_launch_program=['interpreter','program','{connection_file_name}']
""")
cmd = [ expanduser(_.format(connection_file_name=fname)) for _ in self.kernel_launch_program]
return Popen(cmd)