Repository navigation
Todo
Labels
area: lifecycleServer start, context managers, ownership, get-or-create, discovery, leases, program lifetimeenhancement
Milestone
Description
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 intopytest_plugin). - Tooling that inspects running local
tmuxinstances (dashboards,libtmux-mcp, diagnostic CLIs) has to scan/tmp/tmux-<euid>/and$TMUX_TMPDIRmanually and probe each socket for liveness.
Proposal
- Add
Server.private(*, root=None, config_file="/dev/null")as a non-pytest context manager that creates a0700temporary directory, yields an isolatedServer(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 localServerhandles across$TMUX_TMPDIRand/tmp/tmux-<euid>without mutating or starting dead sockets.
References
- Quickstart / standalone-example motivation: Quickstart starts tmux with the CLI before using libtmux #856, Add a standalone, CI-run example program for each core capability #815
- Open socket-discovery draft PR: Lobby(feat): Discover local tmux servers #764
- Sister port tracking issue: libtmux-go#175
- Borrowed-server
Server.__exit__safety:Server.__exit__kills any live server, including one it did not start #724
Metadata
Metadata
Assignees
Labels
area: lifecycleServer start, context managers, ownership, get-or-create, discovery, leases, program lifetimeenhancement
Type
Projects
- StatusShow more project fieldsTodo
Activity
[-]Add `Server.private()` context manager and `discover_servers()`[/-][+]Add `Server.private()` context manager[/+]