Skip to content

Commit

Permalink
Merge pull request #2628 from rgbkrk/kernel-communication
Browse files Browse the repository at this point in the history
Kernel communication
  • Loading branch information
theengineear committed Mar 5, 2018
2 parents 373596f + 14a5950 commit a3be390
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
16 changes: 8 additions & 8 deletions applications/desktop/src/notebook/epics/zeromq-kernels.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import type { NewKernelAction } from "@nteract/core/src/actionTypes";

import type { KernelInfo, LocalKernelProps } from "@nteract/core/src/state";

import { selectors, actions, actionTypes, state } from "@nteract/core";
import { selectors, actions, actionTypes } from "@nteract/core";

import {
createMessage,
Expand Down Expand Up @@ -92,7 +92,7 @@ export function launchKernelObservable(
observer.next(actions.setNotebookKernelInfo(kernelSpec));

const kernel: LocalKernelProps = {
kernelRef: state.createKernelRef(),
kernelRef,
type: "zeromq",
hostRef: null,
channels,
Expand Down Expand Up @@ -188,10 +188,10 @@ export const launchKernelEpic = (
// TODO: Do the async version of `ipc.send`, potentially coordinate with main process
ipc.send("nteract:ping:kernel", action.payload.kernelSpec);

let cleanupOldKernel$ = empty();

// Kill the old kernel by emitting the action to kill it
const oldKernelRef = selectors.currentKernelRef(store.getState());

// Kill the old kernel by emitting the action to kill it if it exists
let cleanupOldKernel$ = empty();
if (oldKernelRef && oldKernelRef !== action.payloadRef) {
cleanupOldKernel$ = of(
actions.killKernel({ restarting: false, kernelRef: oldKernelRef })
Expand Down Expand Up @@ -367,7 +367,7 @@ export function watchSpawn(action$: *, store: *) {
// We both set the state and make it easy for us to log the error
observer.next(
actions.setExecutionState({
kernelStatus: "errored",
kernelStatus: "process errored",
kernelRef: action.payload.kernelRef
})
);
Expand All @@ -377,7 +377,7 @@ export function watchSpawn(action$: *, store: *) {
spawn.on("exit", () => {
observer.next(
actions.setExecutionState({
kernelStatus: "exited",
kernelStatus: "process exited",
kernelRef: action.payload.kernelRef
})
);
Expand All @@ -386,7 +386,7 @@ export function watchSpawn(action$: *, store: *) {
spawn.on("disconnect", () => {
observer.next(
actions.setExecutionState({
kernelStatus: "disconnected",
kernelStatus: "process disconnected",
kernelRef: action.payload.kernelRef
})
);
Expand Down
1 change: 0 additions & 1 deletion applications/desktop/src/notebook/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export function promptUserAboutNewKernel(
const kernelRef = stateModule.createKernelRef();

store.dispatch(
// TODO: get a KernelRef here and use it in action.
actions.launchKernelByName({
kernelSpecName: kernel.kernelSpecName,
cwd,
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/reducers/core/entities/kernels.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ const byRef = (state = Immutable.Map(), action) => {
case actionTypes.SET_LANGUAGE_INFO:
// TODO: Should the kernel hold language info?
return state;
case actionTypes.KILL_KERNEL_SUCCESSFUL:
return state.setIn([action.payload.kernelRef, "status"], "killed");
case actionTypes.KILL_KERNEL_FAILED:
return state.setIn(
[action.payload.kernelRef, "status"],
"failed to kill"
);
case actionTypes.RESTART_KERNEL:
return state.setIn([action.payload.kernelRef, "status"], "restarting");
case actionTypes.LAUNCH_KERNEL:
case actionTypes.LAUNCH_KERNEL_BY_NAME:
return state.setIn([action.payload.kernelRef, "status"], "launching");
case actionTypes.SET_EXECUTION_STATE:
return state.setIn(
[action.payload.kernelRef, "status"],
Expand Down

0 comments on commit a3be390

Please sign in to comment.