# Buggy code
def start_kernel_from_session(
    self, kernel_id, kernel_name, connection_info, process_info, launch_args
):
    # Create a KernelManger instance and load connection and process info, then confirm the kernel is still
    # alive.
    constructor_kwargs = {}
    if self.kernel_spec_manager:
        constructor_kwargs["kernel_spec_manager"] = self.kernel_spec_manager

    # Construct a kernel manager...
    km = self.kernel_manager_factory(
        connection_file=os.path.join(self.connection_dir, "kernel-%s.json" % kernel_id),
        parent=self,
        log=self.log,
        kernel_name=kernel_name,
        **constructor_kwargs,
    )

    # Load connection info into member vars - no need to write out connection file
    km.load_connection_info(connection_info)

    km._launch_args = launch_args

    # Construct a process-proxy
    if km.kernel_spec.process_proxy_class:
        process_proxy_class = import_item(km.kernel_spec.process_proxy_class)
        kw = {"env": {}}
        km.process_proxy = process_proxy_class(
            km, km.kernel_spec.process_proxy_connection_file_mode, **kw
        )
        km.process_proxy.load_process_info(process_info)

        # Confirm we can even poll the process.  If not, remove the persisted session.
        if km.process_proxy.poll() is False:
            return False

    km.kernel = km.process_proxy
    km.start_restarter()
    km._connect_control_socket()
    self._kernels[kernel_id] = km
    self._kernel_connections[kernel_id] = 0
    self.start_watching_activity(kernel_id)
    self.add_restart_callback(
        kernel_id,
        lambda: self._handle_kernel_died(kernel_id),
        "dead",
    )
    # Only initialize culling if available.  Warning message will be issued in gatewayapp at startup.
    func = getattr(self, "initialize_culler", None)
    if func:
        func()
    return True


# Traceback (AttributeError)
[D 2017-08-03 15:27:28.840 KernelGatewayApp] Found kernel python2 in /usr/share/jupyter/kernels
Traceback (most recent call last):
File "/usr/bin/jupyter-kernelgateway", line 11, in <module>
load_entry_point('jupyter-kernel-gateway', 'console_scripts', 'jupyter-kernelgateway')()
File "/usr/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/usr/lib/python2.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "/root/elyra/kernel_gateway/gatewayapp.py", line 352, in initialize
self.init_configurables()
File "/root/elyra/kernel_gateway/gatewayapp.py", line 402, in init_configurables
self.kernel_session_manager.start_sessions()
File "/root/elyra/kernel_gateway/services/sessions/kernelsessionmanager.py", line 83, in start_sessions
if not self._start_session(kernel_session):
File "/root/elyra/kernel_gateway/services/sessions/kernelsessionmanager.py", line 96, in _start_session
launch_args=kernel_session['launch_args'])
File "/root/elyra/kernel_gateway/services/kernels/remotemanager.py", line 55, in start_kernel_from_session
km.process_proxy = process_proxy_class(km, km.kernel_spec.process_proxy_connection_file_mode, **kw)
AttributeError: 'RemoteKernelSpec' object has no attribute 'process_proxy_connection_file_mode'

# Fixed code
def start_kernel_from_session(
    self, kernel_id, kernel_name, connection_info, process_info, launch_args
):
    # Create a KernelManger instance and load connection and process info, then confirm the kernel is still
    # alive.
    constructor_kwargs = {}
    if self.kernel_spec_manager:
        constructor_kwargs["kernel_spec_manager"] = self.kernel_spec_manager

    # Construct a kernel manager...
    km = self.kernel_manager_factory(
        connection_file=os.path.join(self.connection_dir, "kernel-%s.json" % kernel_id),
        parent=self,
        log=self.log,
        kernel_name=kernel_name,
        **constructor_kwargs,
    )

    # Load connection info into member vars - no need to write out connection file
    km.load_connection_info(connection_info)

    km._launch_args = launch_args

    # Construct a process-proxy
    if km.kernel_spec.process_proxy_class:
        process_proxy_class = import_item(km.kernel_spec.process_proxy_class)
        kw = {"env": {}}
        km.process_proxy = process_proxy_class(km)
        km.process_proxy.load_process_info(process_info)

        # Confirm we can even poll the process.  If not, remove the persisted session.
        if km.process_proxy.poll() is False:
            return False

    km.kernel = km.process_proxy
    km.start_restarter()
    km._connect_control_socket()
    self._kernels[kernel_id] = km
    self._kernel_connections[kernel_id] = 0
    self.start_watching_activity(kernel_id)
    self.add_restart_callback(
        kernel_id,
        lambda: self._handle_kernel_died(kernel_id),
        "dead",
    )
    # Only initialize culling if available.  Warning message will be issued in gatewayapp at startup.
    func = getattr(self, "initialize_culler", None)
    if func:
        func()
    return True