Skip to content

Commit 39e87af

Browse files
committed
docs(CHANGES): Bounded tmux commands
what: - Record the `timeout` parameter on `wait_for` and the `cmd` chain, and the `TmuxCommandTimeout` it raises, under `What's new`.
1 parent 57ad5da commit 39e87af

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

CHANGES

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ $ uvx --from 'libtmux' --prerelease allow python
4545
_Notes on the upcoming release will go here._
4646
<!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->
4747

48+
### What's new
49+
50+
#### Bounded tmux commands (#735)
51+
52+
{meth}`Server.wait_for() <libtmux.Server.wait_for>` takes a `timeout` in seconds.
53+
A tmux channel is a rendezvous with no clock on it: when the pane that was going
54+
to signal is killed, exits early, or has its window closed, the waiter blocks for
55+
the life of the process. `server.wait_for(channel, timeout=60)` turns that into
56+
a {exc}`~libtmux.exc.TmuxCommandTimeout` you can catch. It subclasses
57+
{exc}`~libtmux.exc.WaitTimeout`, so existing handlers keep working, and it
58+
carries the command that was killed and the bound it exceeded.
59+
60+
The bound is available to any tmux command, not just `wait-for`.
61+
{meth}`Server.cmd() <libtmux.Server.cmd>`,
62+
{meth}`Session.cmd() <libtmux.Session.cmd>`,
63+
{meth}`Window.cmd() <libtmux.Window.cmd>`,
64+
{meth}`Pane.cmd() <libtmux.Pane.cmd>`, and
65+
{class}`~libtmux.common.tmux_cmd` beneath them all accept `timeout`, and all
66+
kill and reap the tmux process before raising, so an expiry leaves nothing
67+
behind. The default, `None`, waits as long as tmux takes.
68+
69+
See {ref}`automation-patterns` for waiting on a channel instead of polling.
70+
4871
### Documentation
4972

5073
#### Automation patterns waits for tmux instead of guessing (#734)

docs/topics/automation_patterns.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ block on that channel with {meth}`~libtmux.Server.wait_for`. tmux remembers a si
126126
sent before the waiter starts, so this has no lost-wakeup race. It also avoids
127127
confusing the shell's echoed command with the command's output.
128128

129-
{meth}`~libtmux.Server.wait_for` has no timeout. Make sure every expected exit path
130-
reaches `tmux wait-for -S` so a failed command cannot leave your script blocked.
129+
{meth}`~libtmux.Server.wait_for` waits indefinitely unless you give it a `timeout`.
130+
Either make sure every expected exit path reaches `tmux wait-for -S`, or bound the
131+
wait, so a failed command cannot leave your script blocked.
131132
Channels are server-wide, so give each in-flight command a distinct channel name.
132133

133134
```python

0 commit comments

Comments
 (0)