The expect Command And The Tk Event Loop
When waiting inside of expect (or interact) commands, the Tk event loop is still active. This means that the user can, for example, press buttons on the screen and Tk will respond to the buttons while the script is executing an expect command.
While any specific action is being executed from the Tk event loop, the original expect command cannot return. If the user presses a button that kicks off, say, another expect command, the original expect command cannot return until the new expect command returns. (This is true for any command in Tk, not just expect commands.)
If both expect commands read from the same spawn id, the later one will see all the buffered data already received. The new expect command can match data that the original expect command had read but not matched.
All of the descriptions so far are identical to the way Expect works without Tk but in the presence of signals. expect commands that are triggered by signal handlers suspend any currently active expect commands.