Skip to main content

Jupyterlab extension to kill unused kernels, terminals and workspaces. User can configure the idle time (minutes) after which the resource will be released automatically. This helps with the locked memory, insane number of terminals opened etc.

Project description

jupyterlab_kernel_terminal_workspace_culler_extension

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

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

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
  • Session culling - Remove stale sessions based on associated kernel activity
  • 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
Session timeout 10080 min (7 days) Idle sessions 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: Based on WebSocket activity. If the browser tab is closed, activity stops being recorded even if the terminal process is running. For long-running jobs, use nohup, screen, or tmux.

Sessions: Based on the associated kernel's last_activity.

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: The terminal will be culled after the timeout since WebSocket activity stops when the browser closes. 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.

Uninstall

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

Project details


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.3.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_kernel_terminal_workspace_culler_extension-1.0.3.tar.gz
Algorithm Hash digest
SHA256 87259cd40355ba84591b6e64a74d7cd63bd00b37a552962344aa8a89473272bb
MD5 cea6008613d5ee0626284048928f9147
BLAKE2b-256 e16ad518088766acc04b9379387772660bb0d69e6bae87f0181642917816c25d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jupyterlab_kernel_terminal_workspace_culler_extension-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b0d980b58b5ebd21bbf2b37d924d42c0aed15d66a7bbd6dc9e9de278e2e1e06d
MD5 6a09a0968f0123ac55ea96b3d5dee6aa
BLAKE2b-256 8c3db4d1a3490f14ddb7a9505f1261c4ae6e1e9b054923167e86ac920304bf32

See more details on using hashes here.

Supported by

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