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

Kernel communication #2628

Merged
merged 4 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
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
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