Skip to content

Commit 5d304cb

Browse files
committed
Docs(topics[automation]): Wait for tmux, don't guess
why: The examples slept a fixed amount and then read the pane. Measured, send_keys to visible in capture_pane is 100ms at the median under a parallel test run, so the 100ms sleeps had no headroom at all -- the "Capturing output between markers" example fails deterministically at --reruns 0 today, and the repo default of --reruns=2 hides it. Several checks were also searching the joined capture, which matches the command tmux echoed onto the pane and is true before the shell has run. what: - Have commands signal a tmux channel and block on Server.wait_for, which returns when the command is actually done - Compare whole captured lines instead of searching the joined capture - Keep sleeps only where the example is about elapsed time itself
1 parent be7c8c1 commit 5d304cb

2 files changed

Lines changed: 274 additions & 168 deletions

File tree

CHANGES

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ _Notes on the upcoming release will go here._
4747

4848
### Documentation
4949

50+
#### Automation patterns waits for tmux instead of guessing (#734)
51+
52+
The examples on {ref}`automation-patterns` waited for a command to finish by
53+
sleeping a fixed amount and then reading the pane. A sleep long enough to be
54+
safe is dead time on every run, and one short enough to feel quick reports
55+
failure on a busy machine.
56+
57+
They now have the command signal a channel when it finishes and block on that
58+
with {meth}`Server.wait_for() <libtmux.Server.wait_for>`, which returns the
59+
moment the command is done. Checks compare whole captured lines rather than
60+
searching the joined capture, because {meth}`~libtmux.Pane.capture_pane`
61+
returns the command tmux echoed onto the pane -- a substring search matches
62+
that echo and is already true before the shell has run.
63+
5064
#### Cleaner `from_env` examples (#719)
5165

5266
The rendered examples for {meth}`Pane.from_env() <libtmux.Pane.from_env>` and

0 commit comments

Comments
 (0)