Skip to main content

jupyterlab_kernel_terminal_workspace_culler_extension

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO Donate PayPal

[!TIP] This extension is part of the stellars_jupyterlab_extensions metapackage. Install all Stellars extensions at once: pip install stellars_jupyterlab_extensions

Automatically cull idle kernels, terminals, and workspaces after configurable timeout periods. Helps manage system resources by cleaning up unused resources that accumulate during long JupyterLab usage.

Resource Culler Screenshot

Features

  • Idle kernel culling - Shut down kernels idle beyond timeout (checks execution_state and last_activity)
  • Idle terminal culling - Close terminals with no WebSocket activity beyond timeout
  • Workspace culling - Remove stale JupyterLab workspaces (auto-0, auto-k, etc.) based on last modified time
  • Configurable timeouts - All timeouts adjustable via JupyterLab Settings
  • Notifications - Optional toast notifications when resources are culled (requires jupyterlab-notifications)
  • Server-side detection - Uses tornado PeriodicCallback for accurate activity tracking

Default Settings

Setting Default Description
Kernel timeout 60 min (1 hour) Idle kernels culled after this period
Terminal timeout 60 min (1 hour) Inactive terminals culled after this period
Disconnected only enabled Only cull terminals with no open browser tab
Workspace culling enabled Cull stale workspaces (default workspace protected)
Workspace timeout 10080 min (7 days) Stale workspaces culled after this period
Check interval 5 min How often the culler checks for idle resources
Notifications enabled Show notification when resources are culled

How Idle Detection Works

Kernels: Checked for execution_state (busy kernels are never culled) and last_activity timestamp. A kernel is idle when it's not executing and hasn't had activity beyond the timeout.

Terminals: A terminal referenced by any existing workspace is never culled - the workspace must be culled first, which releases its terminals unless another surviving workspace still references them (the cascade). Beyond that, only terminals with no active browser tab are culled by default (controlled by "Only Cull Disconnected Terminals" setting). When a terminal tab is open, it maintains a WebSocket connection and won't be culled regardless of idle time. Once the tab is closed or disconnected, the terminal becomes eligible for culling one full idle timeout later.

Workspaces: Based on the workspace file's last_modified timestamp. JupyterLab creates auto-named workspaces (auto-0, auto-k, etc.) when you open multiple windows. Only auto-named workspaces are culled - the default workspace and named workspaces are never culled. Culling a workspace releases the terminals it referenced, so they can be culled in the same pass (the cascade).

Note: Terminal culling sends SIGHUP to the terminal process. Processes started with nohup will survive culling.

Installation

Requires JupyterLab 4.0.0 or higher.

pip install jupyterlab-kernel-terminal-workspace-culler-extension

Configuration

Open JupyterLab Settings (Settings -> Settings Editor) and search for "Resource Culler" to adjust timeouts and enable/disable culling for each resource type.

Logs

Culling actions are logged at INFO level with [Culler] prefix:

[Culler] CULLING KERNEL abc123 - idle 65.2 minutes (threshold: 60)
[Culler] Kernel abc123 culled successfully
[Culler] CULLING TERMINAL 1 - idle 62.1 minutes (threshold: 60)
[Culler] Terminal 1 culled successfully

Run JupyterLab with --log-level=INFO to see culling activity.

FAQ

Q: My long-running calculation was killed. How do I prevent this?

Two options:

  1. Increase timeout: Go to Settings -> Settings Editor -> Resource Culler and increase the kernel/terminal timeout
  2. Use a terminal multiplexer: Run calculations inside screen or tmux - these survive terminal culling
# Using screen
screen -S mysession
python long_calculation.py
# Detach with Ctrl+A, D

# Using tmux
tmux new -s mysession
python long_calculation.py
# Detach with Ctrl+B, D

Q: Will closing my browser tab kill my running process?

For terminals: By default, terminals are only culled when the browser tab is closed (disconnected). After closing the tab, the terminal will be culled once the idle timeout expires. Foreground processes receive SIGHUP. Use nohup, screen, or tmux for processes that must survive.

For kernels: The kernel continues running. Activity is tracked server-side, so a busy kernel won't be culled even if the browser is closed.

Q: What happens to processes started with nohup?

They survive terminal culling. nohup makes processes ignore SIGHUP, which is the signal sent when a terminal closes.

Q: How do I disable culling entirely?

Go to Settings -> Settings Editor -> Resource Culler and uncheck "Enable Kernel Culling" and "Enable Terminal Culling".

Q: Can I see when resources were culled?

Yes. Run JupyterLab with --log-level=INFO to see [Culler] log messages. If you have jupyterlab-notifications installed, you'll also see toast notifications.

CLI

The extension includes a command-line tool for listing and culling resources from the terminal.

# Show help
jupyterlab_kernel_terminal_workspace_culler

# List all resources and their idle times
jupyterlab_kernel_terminal_workspace_culler list

# List as JSON
jupyterlab_kernel_terminal_workspace_culler list --json

# Show what would be culled (dry run)
jupyterlab_kernel_terminal_workspace_culler cull --dry-run

# Cull idle resources
jupyterlab_kernel_terminal_workspace_culler cull

# Cull and output as JSON
jupyterlab_kernel_terminal_workspace_culler cull --json

# Custom timeouts (minutes)
jupyterlab_kernel_terminal_workspace_culler cull --kernel-timeout 30 --terminal-timeout 120

# Cull workspaces idle > 1 minute (default is 7 days)
jupyterlab_kernel_terminal_workspace_culler cull --workspace-timeout 1

# Also cull terminals that still have an open browser tab (default: skip them)
jupyterlab_kernel_terminal_workspace_culler cull --include-connected

By default cull skips terminals with an open browser tab, matching the extension's disconnected-only behavior. Pass --include-connected to cull them anyway.

The CLI auto-discovers running Jupyter servers. You can also set environment variables:

  • JUPYTER_SERVER_URL - server URL (e.g., http://localhost:8888/)
  • JUPYTER_TOKEN - authentication token

Uninstall

pip uninstall jupyterlab-kernel-terminal-workspace-culler-extension

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file jupyterlab_kernel_terminal_workspace_culler_extension-1.0.24.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_kernel_terminal_workspace_culler_extension-1.0.24.tar.gz
Algorithm Hash digest
SHA256 a94b42f5b5089f7f28ed0e817b1b64e365b2b8952f5d5e6c855d343e550af0c2
MD5 faceb674d958bcbfdc787c3ce0c4833c
BLAKE2b-256 9bc14bff0c4579355116c4dd20307cd34312eb1ac0a11e3fdd15497e2063a7af

See more details on using hashes here.

File details

Details for the file jupyterlab_kernel_terminal_workspace_culler_extension-1.0.24-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_kernel_terminal_workspace_culler_extension-1.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 9e81e1a0efa1485b3e15398acfc77932318588a4b2742c8c42e9c50c1485b89f
MD5 303e1a42f4d6481368257114b21848b5
BLAKE2b-256 ebbbb031445ce54e4a1e8849cba079e7ff776daa0f5b863c62e992c39538f74e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.24 This release

2 files

1.0.23

2 files

1.0.22

2 files

1.0.21

2 files

1.0.20

2 files

1.0.17

2 files

1.0.5

2 files

1.0.3

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page