Esempio n. 1
0
        protected static T GetRequest(JupyterRequestContext context)
        {
            var request = context.GetRequestContent <T>() ??
                          throw new InvalidOperationException(
                                    $"Request Content must be a not null {typeof(T).Name}");

            return(request);
        }
        public Task Handle(JupyterRequestContext context)
        {
            var executeRequest = context.GetRequestContent <ExecuteRequest>() ?? throw new InvalidOperationException($"Request Content must be a not null {typeof(ExecuteRequest).Name}");

            context.RequestHandlerStatus.SetAsBusy();
            var command   = new SubmitCode(executeRequest.Code);
            var id        = command.Id;
            var transient = new Dictionary <string, object> {
                { "display_id", id.ToString() }
            };
            var executionCount = executeRequest.Silent ? _executionCount : Interlocked.Increment(ref _executionCount);

            _openRequests[id] = new OpenRequest(context, executeRequest, executionCount, id, transient);
            return(_kernel.SendAsync(command));
        }