notebooks

package
v0.16.521 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notebooks keeps explicitly started Python kernels. It never reads a notebook's kernelspec, runs a cell on open, or writes the notebook back to disk.

Index

Constants

View Source
const (
	MaxSessions      = 16
	MaxOwnerSessions = 4
	MaxCodeBytes     = 256 << 10
	MaxOutputBytes   = 4 << 20
	MaxOutputs       = 1000
	ExecuteTimeout   = 120 * time.Second
	StartupTimeout   = 30 * time.Second
	IdleTimeout      = 30 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct{ Code, Message string }

Error is an actionable refusal, not a Python cell exception (those are outputs).

func (*Error) Error

func (e *Error) Error() string

type Key

type Key struct{ Owner, Conversation, Path string }

Key must be made by the caller after authorizing the owner and resolving Path to an accessible, canonical notebook in the conversation's writable folder.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager's lock protects only bookkeeping; interrupt/shutdown never wait for an execution lock. A failed or timed-out helper is discarded, not reused out of sync.

func New

func New() *Manager

func (*Manager) Close

func (m *Manager) Close()

Close waits for every started helper (including one still starting) to be reaped.

func (*Manager) CloseConversation

func (m *Manager) CloseConversation(conv string)

func (*Manager) Execute

func (m *Manager) Execute(ctx context.Context, key Key, code string) (out Result, err error)

func (*Manager) Interrupt

func (m *Manager) Interrupt(ctx context.Context, key Key) (State, error)

func (*Manager) Restart

func (m *Manager) Restart(ctx context.Context, key Key) (out State, err error)

func (*Manager) Shutdown

func (m *Manager) Shutdown(key Key) State

func (*Manager) Status

func (m *Manager) Status(key Key) State

Status does not create a session, probe Python, or extend its idle lifetime.

type Result

type Result struct {
	Outputs        []json.RawMessage `json:"outputs"`
	ExecutionCount *int              `json:"execution_count"`
	Status         string            `json:"status"`
}

type State

type State struct {
	State  string `json:"state"`
	Kernel string `json:"kernel,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL