Repository navigation
In review
Labels
area: lifecycleServer start, context managers, ownership, get-or-create, discovery, leases, program lifetimebehavior-changeFixes a bug by changing observable or documented behaviour; needs a minor releaseenhancement
Milestone
Description
Summary
Emit a FutureWarning when a looked-up or reused Session, Window, or Pane enters a with block without an explicit kill_on_exit argument, ahead of changing __exit__ to kill only handles created by that call (#925, #804).
Motivation
0.69.0(Scoping a Server no longer kills it #728) changedwith Server()to preserve running servers unlesskill_on_exit=True, whileSession.__exit__,Window.__exit__, andPane.__exit__still unconditionally kill any live target on block exit (0.68.0documented that caveat onSession.new_window(..., select_existing=True)in Session(docs[new_window]): NoteWindow.__exit__onselect_existingreuse #926).- Flipping
{Session, Window, Pane}.__exit__straight to killing only created handles protects shared sessions and windows, whereas existing test suites or cleanup scripts that wrotewith server.sessions.get(...):orwith session.new_window(..., select_existing=True):as a teardown block would leave sessions, windows, or panes running with no diagnostic.
Proposal
- Stage safe handle teardown across two stacked pull requests:
- Deprecation PR (
0.72.0): record creation provenance (handle.created,TrueonServer.new_session(), newly createdSession.new_window(),Window.split(),Pane.split(), andPane.new_pane();Falseon looked-up,from_env(),from_*_id(), andselect_existing=Truereused handles) and addkill_on_exit: bool | None = NoneonSession,Window, andPane. TargetSession.__exit__bysession_idwhen available rather than prefix-matchingsession_name. Whenkill_on_exit is Noneandhandle.createdisFalse, emit aFutureWarningon__enter__namingkill_on_exit=Trueandkill_on_exit=Falsewhile keeping current teardown behavior for one release cycle, and document the transition inMIGRATIONtables and runnable examples. - Enforcement PR (
0.73.0, stacked on the deprecation PR): whenkill_on_exit is None, kill on__exit__only whenhandle.createdisTrue, leaving looked-up and reused handles running without warning, and update theMIGRATIONtables andSession.new_window(select_existing=True)documentation.
- Deprecation PR (
Alternatives
- Changing
{Session, Window, Pane}.__exit__to preserve unowned handles in a single release with no warning: rejected because callers relying onwith looked_up_session:for test teardown would leak tmux objects silently rather than learning to passkill_on_exit=Trueor call.kill().
References
- Lifecycle roadmap and ownership tracking: Lifecycle roadmap: overlaps, conflicts, blockers and tmux version gates #925, Create or reuse tmux resources with explicit cleanup ownership #804, Add
get_or_create_window()andget_or_create_session()helpers #916, 0.63.x and beyond Roadmap #907 v0.70.0touchpoints:src/libtmux/session.pyL216-L255,src/libtmux/window.pyL229-L265,src/libtmux/pane.pyL227-L265,MIGRATION
Metadata
Metadata
Assignees
Labels
area: lifecycleServer start, context managers, ownership, get-or-create, discovery, leases, program lifetimebehavior-changeFixes a bug by changing observable or documented behaviour; needs a minor releaseenhancement
Type
Projects
- StatusShow more project fieldsNo status
Activity
Session/Window/Pane(feat[ctx]): Preserve unowned handles
Session/Window/Pane(feat[ctx]): Warn on unowned __enter__
Session/Window/Pane(feat[ctx]): Preserve unowned handles