##// END OF EJS Templates
Merge pull request #2854 from minrk/2853b...
Merge pull request #2854 from minrk/2853b Move kernel code into IPython.kernel inprocess Kernel in kernel.inprocess zmq Kernel in kernel.zmq KernelManager stuff and ulities in top-level kernel Main functional change: allow custom kernel Popen command - [x] adds `KernelManager.kernel_cmd` configurable for launching a custom kernel - [x] splits entry_point.base_launch_kernel into two steps: making the launch cmd and launching the subprocess - [x] figure out where the entry_point functions belong, if it should be anywhere else - [x] move IPython.zmq.kernelmanagerabc to IPython.kernel.kernelmanagerabc - [x] move IPython.lib.kernel/IPython/zmq.entry_point to IPython.kernel.launcher / connect - [x] move zmq.ipkernelapp.IPKernelApp to zmq.kernelapp (I'll look at merging the classes, and see if it makes - [x] move IPython.zmq to IPython.kernel.zmq - [x] move IPython.inprocess to IPython.kernel.inprocess - [x] move embed_kernel from zmq.ipkernelapp to zmq.embed - [x] move MultiKernelManager to IPython.kernel.multikernelmanager. - [x] move IPython.zmq.blockingkernelmanager to IPython.kernel.blockingkernelmanager. - [x] move IPython.zmq.kernelmanager to IPython.kernel.kernelmanager. - [x] move IPython.ipkernel.Kernel to IPython.kernel.kernel.

File last commit:

r9372:37f32253
r9402:5db16721 merge
Show More
factory.py
79 lines | 2.9 KiB | text/x-python | PythonLexer
"""Base config factories.
Authors:
* Min RK
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2010-2011 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
#-----------------------------------------------------------------------------
import logging
import os
import zmq
from zmq.eventloop.ioloop import IOLoop
from IPython.config.configurable import Configurable
from IPython.utils.localinterfaces import LOCALHOST
from IPython.utils.traitlets import Integer, Instance, Unicode
from IPython.parallel.util import select_random_ports
from IPython.kernel.zmq.session import Session, SessionFactory
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class RegistrationFactory(SessionFactory):
"""The Base Configurable for objects that involve registration."""
url = Unicode('', config=True,
help="""The 0MQ url used for registration. This sets transport, ip, and port
in one variable. For example: url='tcp://%s:12345' or
url='epgm://*:90210'"""
% LOCALHOST) # url takes precedence over ip,regport,transport
transport = Unicode('tcp', config=True,
help="""The 0MQ transport for communications. This will likely be
the default of 'tcp', but other values include 'ipc', 'epgm', 'inproc'.""")
ip = Unicode(LOCALHOST, config=True,
help="""The IP address for registration. This is generally either
'127.0.0.1' for loopback only or '*' for all interfaces.
[default: '%s']""" % LOCALHOST)
regport = Integer(config=True,
help="""The port on which the Hub listens for registration.""")
def _regport_default(self):
return select_random_ports(1)[0]
def __init__(self, **kwargs):
super(RegistrationFactory, self).__init__(**kwargs)
self._propagate_url()
self._rebuild_url()
self.on_trait_change(self._propagate_url, 'url')
self.on_trait_change(self._rebuild_url, 'ip')
self.on_trait_change(self._rebuild_url, 'transport')
self.on_trait_change(self._rebuild_url, 'regport')
def _rebuild_url(self):
self.url = "%s://%s:%i"%(self.transport, self.ip, self.regport)
def _propagate_url(self):
"""Ensure self.url contains full transport://interface:port"""
if self.url:
iface = self.url.split('://',1)
if len(iface) == 2:
self.transport,iface = iface
iface = iface.split(':')
self.ip = iface[0]
if iface[1]:
self.regport = int(iface[1])