private void MonitorChannels() { var poll = ZPollItem.CreateReceiver(); ZMessage incoming; ZError error; while (!_monitorChannnelsCts.IsCancellationRequested) { if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (StdInSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (IoPubSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (ShellSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (_monitorChannnelsCts.IsCancellationRequested) { break; } if (ControlSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } } ContinueShutdown.Set(); }
public JupyterMessage Execute(string code) { FlushMessages(); CurrentState = KernelState.busy; SendShell( JupyterMessage.Header.MsgType.execute_request, new JupyterMessage.ExecuteRequestContent { code = code, silent = false, store_history = true, user_expressions = null, allow_stdin = true, stop_on_error = false }, null); var poll = ZPollItem.CreateReceiver(); ZMessage incoming; ZError error; while (CurrentState != KernelState.idle) { if (StdInSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } if (IoPubSocket.PollIn(poll, out incoming, out error, TimeSpan.FromMilliseconds(100))) { ProcessMessage(incoming, error); } } var replyMessage = ShellSocket.ReceiveMessage(); return(ParseMessage(replyMessage)); }