Plenty of scripts start something in a tmux pane and then sleep 30 and hope. tmux has a proper way to wait: named channels.
tmux wait-for build-done
That command just sits there. It returns when something, anywhere on the same tmux server, runs:
tmux wait-for -S build-done
The name is free to choose. A typical use is a script that sends a long job to another pane and then waits for it:
tmux send-keys -t build 'make all; tmux wait-for -S build-done' Enter
tmux wait-for build-done
echo "build finished"
With a one second job, the waiting command returns after about a second, which is the time the other pane needs. The other order works too. When the signal comes first, the next wait-for on that name returns at once, so you don’t lose a signal if the job finishes before you start waiting.
Caveats: the signal is sent whether the job succeeded or not, since the ; in the example always continues. Use && or send a different channel name when it fails. The channel name is shared across the whole server, so pick names that won’t collide. There are also -L and -U to lock and unlock a channel, if you want to use it as a mutex between scripts.
Further reading: tmux manual, wait-for