Skip to content

Add Server.private() context manager #872

Todo

Description

@tony

Note

Server discovery (discover_servers()) moved to #924. This issue now covers Server.private() only; the discovery text below is kept for history.

Summary

Non-pytest callers lack a public isolated temporary-server helper (TestServer in src/libtmux/pytest_plugin.py lines 105–185 is test-fixture machinery), and local socket discovery (discover_servers()) has an open draft PR (#764) with no tracking issue.

Motivation

  • Quickstart starts tmux with the CLI before using libtmux #856 notes that standalone scripts, documentation examples, and one-shot automation tasks currently assemble tempfile.TemporaryDirectory + Server(socket_path=..., config_file="/dev/null") + try/finally: server.kill() by hand (or reach into pytest_plugin).
  • Tooling that inspects running local tmux instances (dashboards, libtmux-mcp, diagnostic CLIs) has to scan /tmp/tmux-<euid>/ and $TMUX_TMPDIR manually and probe each socket for liveness.

Proposal

  • Add Server.private(*, root=None, config_file="/dev/null") as a non-pytest context manager that creates a 0700 temporary directory, yields an isolated Server(socket_path=...), kills the server on exit, and removes the directory.
  • Track and finalize discover_servers() (draft PR Lobby(feat): Discover local tmux servers #764) returning discovered local Server handles across $TMUX_TMPDIR and /tmp/tmux-<euid> without mutating or starting dead sockets.

References

Activity

  1. added
    area: lifecycle
    on Nov 21, 2026
  2. changed the title [-]Add `Server.private()` context manager and `discover_servers()`[/-] [+]Add `Server.private()` context manager[/+] on Nov 24, 2026
  3. moved this to Todo in libtmuxon Nov 25, 2026
  4. added this to the 0.71.0 milestone on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: lifecycleenhancement

    Type

    No type

    Projects

    • Status
      Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions