Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// NOTE: we should generate IDs
// We're also setting a session ID within the enchannel-zmq setup, I wonder
// if we should use that
const id = kernel.connectionInfo.key;
messages[id] = [];
kernels[id] = kernel;
const subscription = kernel.channels.subscribe(
(message: JupyterMessage) => {
messages[id].push(message);
}
);
const request = kernelInfoRequest();
messages[id].push(request);
kernel.channels.next(request);
// NOTE: We are going to want to both:
//
// subscription.unsubscribe()
// AND
// kernel.channels.complete()
//
// Within our cleanup code
return {
id,
status: "launched"
};
},
switchMap(({ payload }) => {
const { kernel, kernelName, serverId } = payload;
// Side effect! Get that Kernel Info!
kernel.channel.next(kernelInfoRequest());
return kernel.channel.pipe(
mergeMap(message => {
const actionsArray = [
actions.addKernelMessage({ serverId, kernelName, message })
];
switch (message.header.msg_type) {
case "status":
actionsArray.push(
actions.setKernelStatus({
serverId,
kernelName,
status: message.content.execution_state
})
);
break;
case "kernel_info_reply":
// NOTE: we should generate IDs
// We're also setting a session ID within the enchannel-zmq setup, I wonder
// if we should use that
const id = kernel.connectionInfo.key;
messages[id] = [];
kernels[id] = kernel;
const subscription = kernel.channels.subscribe(
(message: JupyterMessage) => {
messages[id].push(message);
}
);
const request = kernelInfoRequest();
messages[id].push(request);
kernel.channels.next(request);
// NOTE: We are going to want to both:
//
// subscription.unsubscribe()
// AND
// kernel.channels.complete()
//
// Within our cleanup code
return {
id,
status: "launched"
};
},
intervalId = setInterval(() => {
if (kernelInfo) {
clearInterval(intervalId);
return;
}
this.props.kernel.channels.next(messaging.kernelInfoRequest());
}, 300);
}
intervalId = setInterval(() => {
if (kernelInfo) {
clearInterval(intervalId);
return;
}
this.props.kernel.channels.next(messaging.kernelInfoRequest());
}, 300);
}
map(() => state$.value.jupyter.mainChannel.next(kernelInfoRequest())),
ignoreElements()
const sessionId = castToSessionId(session.id);
const kernel: RemoteKernelProps = Object.assign({}, session.kernel, {
type: "websocket",
info: null,
sessionId: sessionId,
cwd,
channels: kernels.connect(
serverConfig,
session.kernel.id,
sessionId
),
kernelSpecName
});
kernel.channels.next(kernelInfoRequest());
return of(
actions.launchKernelSuccessful({
kernel,
kernelRef,
contentRef: action.payload.contentRef,
selectNextKernel: true
})
);
})
);
const kernel: RemoteKernelProps = Object.assign({}, session.kernel, {
type: "websocket",
info: null,
sessionId,
cwd,
channels: kernels.connect(
serverConfig,
session.kernel.id,
sessionId
),
kernelSpecName,
hostRef
});
kernel.channels.next(kernelInfoRequest());
return of(
actions.launchKernelSuccessful({
kernel,
kernelRef,
contentRef: action.payload.contentRef,
selectNextKernel: true
})
);
}),
catchError(error => {