Fix expect() timeout never firing while the stream keeps producing output - #3
Conversation
…eeps producing output Signed-off-by: CarlosFelipeOR <carlosfelipeor@gmail.com>
|
I have read the CLA Document and I hereby sign the CLA |
|
The solution does not seem to be correct. Try changing to just ">" so that the 0 value will cause an exception. |
|
Actually, the read(timeout=0) is treated as non-blocking so if data is there it will read. So expect with timeout=0 should do the same, try only once if data is read and matched then no exception otherwise raise. |
…ries once Signed-off-by: CarlosFelipeOR <carlosfelipeor@gmail.com>
|
Done. Behaviour matrix used to verify it, generated by Claude Opus 5: test_matrix.py
@vzakaznikov could you review it again? |
Close #2
Contributor License Agreement
For more information see https://github.com/testflows/TestFlows/blob/master/CONTRIBUTING.md.
I, the Contributor, have agreed to and signed the CLA.
Description of Changes
expect()only evaluated its deadline inside theexcept TimeoutError:branch, which is reached only whenread()sees no data for 0.1s. With a stream that never goes quiet that branch is never taken, sotimeleftreaches 0 and the loop spins indefinitely.The deadline is now checked on every iteration: search first, so a match that just arrived still wins, then check the deadline, then read. The timeout block is moved unchanged, so
expect_timeout=Truestill returns instead of raising.Verified with the reproducer from #2:
The continuous-stream case overshoots slightly (3.8s for
timeout=3) because the regex search over the accumulated buffer runs before the deadline check. That ordering is deliberate — checking first would discard a match that had just arrived.